Klick auf ContainerGadget?
Verfasst: 01.10.2014 09:41
Hi.
Kann ich abfragen, ob ein Klick auf ein ContainerGadget ausgeführt wurde?
Kann ich abfragen, ob ein Klick auf ein ContainerGadget ausgeführt wurde?
Code: Alles auswählen
Define Event, WindowHandle
Define MousePos.POINT
If OpenWindow(0, 500, 500, 800, 800, "")
ContainerGadget(0, 10, 10, 500, 500, #PB_Container_Single)
Repeat
Event = WaitWindowEvent()
If Event = #WM_LBUTTONUP
GetCursorPos_(@MousePos)
WindowHandle = WindowFromPoint_(PeekQ(@MousePos))
If GadgetID(0) = WindowHandle
Debug "ContainerGadget wurde angeklickt!"
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Code: Alles auswählen
EnableExplicit
Procedure MouseOverGadget(window, gadget)
If (WindowMouseX(window) >= GadgetX(gadget)) And (WindowMouseX(window) <= (GadgetX(gadget) + GadgetWidth(gadget)))
If (WindowMouseY(window) >= GadgetY(gadget)) And (WindowMouseY(window) <= (GadgetY(gadget) + GadgetHeight(gadget)))
ProcedureReturn #True
EndIf
EndIf
EndProcedure
OpenWindow(0, #PB_Ignore, #PB_Ignore, 640, 480, "")
ContainerGadget(0, 50, 50, 200, 200, #PB_Container_Raised)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_LeftClick
If MouseOverGadget(0, 0)
Debug "Container"
EndIf
EndSelect
ForEver
Code: Alles auswählen
EnableExplicit
Procedure MouseOverGadget(window, gadget)
If (WindowMouseX(window) >= GadgetX(gadget)) And (WindowMouseX(window) < (GadgetX(gadget) + GadgetWidth(gadget)))
If (WindowMouseY(window) >= GadgetY(gadget)) And (WindowMouseY(window) < (GadgetY(gadget) + GadgetHeight(gadget)))
ProcedureReturn #True
EndIf
EndIf
EndProcedure
Procedure Event_LeftClick()
If MouseOverGadget(0, 0)
Debug "Container"
EndIf
EndProcedure
OpenWindow(0, #PB_Ignore, #PB_Ignore, 640, 480, "")
ContainerGadget(0, 50, 50, 200, 200, #PB_Container_Raised)
BindEvent(#PB_Event_LeftClick, @Event_LeftClick())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow