Click on TreeGadget image?
Posted: Wed May 27, 2015 1:06 am
Hi,
It used to be possible to determine if the image of a TreeGadget had been clicked on by testing which column was clicked in. However, I believe that a change at some point combined an item's image and text into the same column, so that the test returned the same result for a click on the image and text.
Is there a way to see if ONLY the image has been clicked on? I do need to use checkboxes.
Thank you!
It used to be possible to determine if the image of a TreeGadget had been clicked on by testing which column was clicked in. However, I believe that a change at some point combined an item's image and text into the same column, so that the test returned the same result for a click on the image and text.
Is there a way to see if ONLY the image has been clicked on? I do need to use checkboxes.
Code: Select all
Define SelectedRow, SelectedColumn, ClickedPoint.NSPoint
If OpenWindow(0, 0, 0, 355, 180, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TreeGadget(0, 10, 10, 160, 160, #PB_Tree_CheckBoxes)
CreateImage(0, 16, 16)
If StartDrawing(ImageOutput(0))
Box(0, 0, OutputWidth(), OutputHeight(), RGB(0, 0, 128))
StopDrawing()
EndIf
AddGadgetItem(0, -1, "Item 1", ImageID(0))
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Gadget
If EventType() = #PB_EventType_LeftClick
ClickedPoint\x = WindowMouseX(0)
ClickedPoint\y = WindowHeight(0) - WindowMouseY(0)
CocoaMessage(@ClickedPoint, GadgetID(0), "convertPoint:@", @ClickedPoint, "fromView:", 0)
SelectedRow = CocoaMessage(0, GadgetID(0), "rowAtPoint:@", @ClickedPoint)
SelectedColumn = CocoaMessage(0, GadgetID(0), "columnAtPoint:@", @ClickedPoint)
Debug "column: " + SelectedColumn
SelectedColumn = -1
SelectedRow = -1
EndIf
EndSelect
Until event = #PB_Event_CloseWindow
EndIf