detecting mousedown in a gadget?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.


What is the easier or better way to detect a mousedown in a gadget?

I want to detect whenever the user do a mouse down inside any gadget.

Thanks



Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> I want to detect whenever the user do a mouse down inside any gadget.

:) Isn't that what a gadget event does?


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.
:) Isn't that what a gadget event does?
Im talking about MouseDown, not Click. In fact click is like getting the MouseUp.



Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.


Ofcourse i know how to get a MouseDown event, but i want to know in which gadget does the user do the mouse down, maybe there is some easier way to get it.
ATM im receiving MouseDown event and then using the Mouse-X & Mouse-Y i get if it was inside some gadget but maybe there is another way to do it.



Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Use EventGadgetID() to get the Gadget
where the message comes from.

cya,
...Danilo

(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.
Originally posted by Danilo

Use EventGadgetID() to get the Gadget
where the message comes from.
But i need to know it when the user are still pressing the button, before releasing it :), otherwise i could use the click, but the idea is that the user will mantain pressed the button and then i need to know which gadget are pressed before release it.



Best Regards

Ricardo

Dont cry for me Argentina...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> i need to know it when the user are still pressing the button,
> before releasing it

Do you mean something like this? Note that this example doesn't take
into account if the user has swapped the left/right mouse buttons...

Code: Select all

If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,"Test")
  CreateGadgetList(WindowID())
  bg=ButtonGadget(1,20,20,100,25,"Up")
  Repeat
    ev=WaitWindowEvent() : GetCursorPos_(mouse.POINT)
    If ev=#WM_LBUTTONDOWN And WindowFromPoint_(mouse\x,mouse\y)=bg
      SetGadgetText(1,"Down")
      While GetAsyncKeyState_(#VK_LBUTTON)0 : Sleep_(1) : Wend
      SetGadgetText(1,"Up")      
    EndIf
  Until ev=#PB_EventCloseWindow
EndIf
(Fred: The SetGadgetText command in the docs don't say that it can be
used with ButtonGadgets, which may confuse newbies).


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.


PB you are a champion !!!!

Thanks !!!



Best Regards

Ricardo

Dont cry for me Argentina...
Post Reply