The OS all work differently internally. This sometimes leads to different behaviour of the events that PB passes to you.
In Linux GtkTreeView signal "row-activated" is bound to the double-click by default.
PB-Help: ListViewGadget
The following events are supported through EventType():
#PB_EventType_LeftClick (also fired when the selection change)
#PB_EventType_LeftDoubleClick
#PB_EventType_RightClick
You can also bind your own signals for adaptation.
Code: Select all
;-TOP
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
; Linux signal callback
ProcedureC signal_treeview_button_press_event_cb(*GtkWidget, *Event.GdkEventButton, user_data)
Protected gadget
If *Event\button = 1
gadget = g_object_get_data_(*GtkWidget, "pb_id" ) - 1
PostEvent(#PB_Event_Gadget, GetActiveWindow(), gadget, #PB_EventType_StatusChange)
EndIf
EndProcedure
CompilerEndIf
; ****
EnableExplicit
;- Constant
Enumeration Windows
#Main
EndEnumeration
Enumeration Menus
#Menu
EndEnumeration
Enumeration MenuItems
#MenuExitApplication
EndEnumeration
Enumeration Gadgets
#List
EndEnumeration
Enumeration Statusbar
#Status
EndEnumeration
Enumeration Images
EndEnumeration
;- Global Variable
Global ExitApplication
;- Functions
Procedure UpdateWindow()
Protected x, y, dx, dy, menu, status
menu = MenuHeight()
If IsStatusBar(#Status)
status = StatusBarHeight(#Status)
Else
status = 0
EndIf
x = 0
y = 0
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - menu - status
ResizeGadget(#List, x, y, dx, dy)
EndProcedure
;- Main
Procedure Main()
Protected event, dx, dy
#WinStyle = #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget
dx = 800
dy = 600
If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, dx, dy, "Main Window", #WinStyle)
; Menu
CreateMenu(#Menu, WindowID(#Main))
MenuTitle("File")
MenuItem(#MenuExitApplication, "E&xit")
; Gadgets
ListViewGadget(#List, 0, 0, dx, dy)
; Statusbar
CreateStatusBar(#Status, WindowID(#Main))
AddStatusBarField(#PB_Ignore)
; Init
UpdateWindow()
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
; Test
Define i
For i = 1 To 10
AddGadgetItem(#List, -1, "Text Number " + i)
Next
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
; Bind Linux Event
g_signal_connect_(GadgetID(#List), "button-press-event", @signal_treeview_button_press_event_cb(), 0)
CompilerEndIf
; Main Loop
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Menu
Select EventMenu()
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
Case #PB_Menu_About
Case #PB_Menu_Preferences
Case #PB_Menu_Quit
ExitApplication = #True
CompilerEndIf
Case #MenuExitApplication
ExitApplication = #True
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #List
Select EventType()
Case #PB_EventType_LeftClick
Debug "LeftClick" + GetGadgetText(#List)
Case #PB_EventType_StatusChange
Debug "Signal: " + GetGadgetText(#List)
EndSelect
EndSelect
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Main
ExitApplication = #True
EndSelect
EndSelect
Until ExitApplication
EndIf
EndProcedure : Main()
End