; Module/File: LIG_AddScrollEvent_Wheel.pb ; Function: Adds Event on LIG-scrolling with mousewheel - Linux gtk2 ; Author: Omi ; Date: Oct. 14, 2014 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.31 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ; Link to topic: http://www.purebasic.fr/english/viewtopic.php?p=451443#p451443 ;-------------------------------------------------------------- ; see shardiks example in the link above too (works only on gtk2 w/o a small mod) EnableExplicit ImportC "" gdk_event_get_scroll_deltas(*event, *delta_x, *delta_y); gtk3 g_signal_connect(*instance, detailed_signal.p-utf8, *c_handler, *data, destroy= 0, flags= 0) As "g_signal_connect_data" EndImport ;Object constants #MainWin= 0 #LIG= 0 #WinX= 200 #WinY= 200 #WinW= 420 #WinH= 400 #GDK_SCROLL_SMOOTH= 4 Global.i gEvent, gQuit ProcedureC TV_ScrollWheelEvent(*widget, *event.GdkEventScroll, user_data); callback for scrolling with wheel Protected.d delta_x, delta_y If user_data= #MainWin If *widget= GadgetID(#LIG) Debug "scroll event..." Debug " modifier key: " + Str(*event\state) Debug " direction : " + Str(*event\direction) ;deactivate on gtk2 ... ; If *event\direction = #GDK_SCROLL_SMOOTH ; gdk_event_get_scroll_deltas(*event, @delta_x, @delta_y) ; Debug " delta-x : " + Str(delta_x) ; Debug " delta-y : " + Str(delta_y) ; EndIf Debug "---" EndIf EndIf EndProcedure Procedure CreateWindow_Main() Protected.l I, J Protected.s pText If OpenWindow(#MainWin, #WinX, #WinY, #WinW, #WinH, "Event on mousewheel scroll action", #PB_Window_SystemMenu) ListIconGadget(#LIG, 5, 5, 400, 380, "Col 0", 70, #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_GridLines) For I = 1 To 6 AddGadgetColumn(#LIG, I, "Col " + Str(I), 60) Next I For I = 0 To 25 pText = "" For J = 0 To 6 pText + Str(I) + "x" + Str(J) + Chr(10) Next J AddGadgetItem(#LIG, -1, pText) Next I ; / events an mouse wheel scrolling / g_signal_connect(GadgetID(#LIG), "scroll-event", @TV_ScrollWheelEvent(), #MainWin) EndIf EndProcedure CreateWindow_Main() Repeat gEvent= WaitWindowEvent() Select gEvent Case #PB_Event_CloseWindow gQuit= #True EndSelect Until gQuit ; IDE Options = PureBasic 5.46 LTS Beta 2 (Linux - x86) ; CursorPosition = 10 ; Folding = - ; EnableUnicode ; EnableXP ; SubSystem = gtk2