How to extend/subclass a gadget or window (cross platform)?
How to extend/subclass a gadget or window (cross platform)?
I’ve seen some topics for that but for windows only using API calls. I want to add properties and methods to a gadget or window but should be valid for all supported platforms.
Re: How to extend/subclass a gadget or window (cross platfor
there isn't any cross platform PB function available to do it.
You would need to resort to API's.
For windows you have the native PB function to subclass the window SetWindowCallBack
and you can use this to do the same on Linux (except its global)
In the your call back you need to cast the event to the event type.
You would need to resort to API's.
For windows you have the native PB function to subclass the window SetWindowCallBack
and you can use this to do the same on Linux (except its global)
In the your call back you need to cast the event to the event type.
Code: Select all
ProcedureC WinManCallBack(*event.gdkEvent,window)
Protected *bevent.GdkEventButton
If *event\gdktype = #GDK_BUTTON_PRESS
;cast event to button event
*bevent.GdkEventButton = *event
If *bevent\button = 1
;left
elseif *bevent\button = 3
;right
endif
endif
;Pass control back to pb so it can get events
ProcessPureBasicEvents(*event)
Code: Select all
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
Enumeration -1
;GdkEventTypes
#GDK_NOTHING ; = -1
#GDK_DELETE ; = 0
#GDK_DESTROY; = 1
#GDK_EXPOSE ; = 2
#GDK_MOTION_NOTIFY ;= 3
#GDK_BUTTON_PRESS ;= 4
#GDK_2BUTTON_PRESS; = 5
#GDK_3BUTTON_PRESS ;= 6
#GDK_BUTTON_RELEASE; = 7
#GDK_KEY_PRESS ;= 8
#GDK_KEY_RELEASE ;= 9
#GDK_ENTER_NOTIFY; = 10
#GDK_LEAVE_NOTIFY; = 11
#GDK_FOCUS_CHANGE; = 12
#GDK_CONFIGURE ; = 13
#GDK_MAP ;= 14
#GDK_UNMAP ; = 15
#GDK_PROPERTY_NOTIFY ;= 16
#GDK_SELECTION_CLEAR ;= 17
#GDK_SELECTION_REQUEST ;= 18
#GDK_SELECTION_NOTIFY ;= 19
#GDK_PROXIMITY_IN ;= 20
#GDK_PROXIMITY_OUT ;= 21
#GDK_DRAG_ENTER ; = 22
#GDK_DRAG_LEAVE ; = 23
#GDK_DRAG_MOTION ; = 24
#GDK_DRAG_STATUS ; = 25
#GDK_DROP_START ; = 26
#GDK_DROP_FINISHED ; = 27
#GDK_CLIENT_EVENT ;= 28
#GDK_VISIBILITY_NOTIFY ;= 29
#GDK_NO_EXPOSE ;= 30
#GDK_SCROLL ; = 31
#GDK_WINDOW_STATE; = 32
#GDK_SETTING ;= 33
#GDK_OWNER_CHANGE; = 34
#GDK_GRAB_BROKEN ; = 35
#GDK_DAMAGE ; = 36
EndEnumeration
CompilerIf Defined(GdkEvent,#PB_Structure)=#False
Structure GdkEvent
gdktype.l
StructureUnion
any.GdkEventAny
expose.GdkEventExpose
no_expose.GdkEventNoExpose
visibility.GdkEventVisibility
motion.GdkEventMotion
button.GdkEventButton
scroll.GdkEventScroll
key.GdkEventKey
crossing.GdkEventCrossing
focus_change.GdkEventFocus
configure.GdkEventConfigure
property.GdkEventProperty
selection.GdkEventSelection
proximity.GdkEventProximity
client.GdkEventClient
dnd.GdkEventDND
window_state.GdkEventWindowState
setting.GdkEventSetting
EndStructureUnion
EndStructure
CompilerEndIf
ImportC "-gdk"
gtk_main_do_event( *event.gdkEvent)
gdk_event_handler_set (*func,*mdata,*notify);
EndImport
Macro SetWindowCallback(EventHandler)
gdk_event_handler_set (EventHandler,0,0);
EndMacro
Macro ProcessPureBasicEvents(event)
gtk_main_do_event(event);
EndMacro
CompilerEndIf
Windows 11, Manjaro, Raspberry Pi OS

