A way to know if the mousebutton was pressed or released.
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
A way to know if the mousebutton was pressed or released.
A way to know if the mousebutton was pressed or released.
I had to make my own little procedure to do this.
The command MouseButton() only return if it's down or not.
I had to make my own little procedure to do this.
The command MouseButton() only return if it's down or not.
I like logic, hence I dislike humans but love computers.
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
Maybe it is, sorry then...
Edit:
But it would make the command set more complete.
I think it should be something like this:
Edit:
But it would make the command set more complete.
I think it should be something like this:
Code: Select all
Result = MouseDown(ButtonNumber)
Result = MousePressed(ButtonNumber)
Result = MouseReleased(ButtonNumber)
Result = KeyboardDown(KeyID)
Result = KeyboardPressed(KeyID)
Result = KeyboardReleased(KeyID)
Last edited by Joakim Christiansen on Wed Aug 24, 2005 6:17 pm, edited 2 times in total.
I like logic, hence I dislike humans but love computers.
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
Actually we should be able to know if any button is released or pressed so we don't have to create our own stupid procedures to find it out.
It would make the command set more complete and I recommend functions like this
:
It should be optional and the default one should be #PB_Button_Down
Am I complaining now?
It would make the command set more complete and I recommend functions like this

Code: Select all
If KeyboardKey(#PB_Key_Left,#PB_Button_Pressed)
;do something
EndIf
If MouseButton(#PB_MouseButton_Left,#PB_Button_Released)
;do something
EndIf
Code: Select all
#PB_Button_Down
#PB_Button_Pressed
#PB_Button_Released
;or maybe shorter syntax like #Down, #Pressed, #Released... whatever
Am I complaining now?

first of all, some native rmb support would be nice, as well as mousewheel support!
anyway, i currently use:
anyway, i currently use:
Code: Select all
Procedure.l x_leftmousebutton() ; return current state of left mousebutton
;
; retval: #True - mouse button down
; #False - mouse button up
;
; note: does not use events!
;
If GetSystemMetrics_(#SM_SWAPBUTTON) = 0
ProcedureReturn x_bool(GetAsyncKeyState_(#VK_LBUTTON))
Else
ProcedureReturn x_bool(GetAsyncKeyState_(#VK_RBUTTON))
EndIf
EndProcedure
Procedure.l x_rightmousebutton() ; return current state of right mousebutton
;
; note: does not use events!
;
If GetSystemMetrics_(#SM_SWAPBUTTON) = 0
ProcedureReturn x_bool(GetAsyncKeyState_(#VK_RBUTTON))
Else
ProcedureReturn x_bool(GetAsyncKeyState_(#VK_LBUTTON))
EndIf
EndProcedure
Procedure.l x_mousewheel(mode.l) ; returns number of lines up / down upon using the scrollwheel after a #WM_MOUSEWHEEL event
;
; *** returns number of lines up / down upon using the scrollwheel after a #WM_MOUSEWHEEL event
;
; in: mode.l = 0 - one line per message, return -1 for up, +1 for down
; = 1 - use windows setting for calculating number of lines, from -n to +n
; retval: <0 - up
; >0 - down
;
If mode = 0
d = x_sgn( EventwParam() >> 16 )
Else
;
; #SPI_GETWHEELSCROLLLINES = 104
;
d = 0
SystemParametersInfo_(104,0,@d,0)
d = (EventwParam() >> 16)*d/120
;
EndIf
ProcedureReturn d
EndProcedure
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )