Page 1 of 1
Mouse click detection
Posted: Wed Jan 12, 2005 6:10 am
by TimmyTom
I need to detect mouse click, and then continuously (unlike PB's screwed up Event system that gives me ONE event, no matter how long you hold down or how hard you hit your mouse with a brick (which i started doing after seeing how screwed up PB's mouse event handling is))
I also do not want to use a callback.
So, i need something like GetAsyncKeyState but then for the mouse buttons
I cannot phatom the amount of thinking (or rather, no-thinking) that went into giving us WindowMouseX and WindowMouseY but not a MouseButton function.
Any ideas?
Tim
Posted: Wed Jan 12, 2005 7:15 am
by Randy Walker
Got Problems with documentation or any other gripes? Click around here some and find out how others feel about PureBasic. Then read here consider how little you paid and don't be an ingrate.
viewtopic.php?t=11740&highlight=pay+updates
You are new here and I've only been here (using PureBasic) for a few months. You need to READ to understand why things are as they are. I was also very confused by it all. Developement efforts seem more focused on the program rather than the documentation but you will find (IF YOU LOOK) that PureBasic is fully competent to do virtually anything you want to do under the Windows platform. I have no experience yet with the others but I expect they too grant near complete if not complete access to them as well. As far as documentation, your specific question has already been answered more than once here on this forum... try the SEARCH feature and then R-E-A-D !!
Or if you'd like to post a civil question...
BTW... Welcome to PureBasic
[EDIT] I thought you were new here by your question and no member rating under your name. Now I see "Joined: 18 Aug 2003" so maybe not a newbie.
Posted: Wed Jan 12, 2005 7:18 am
by dracflamloc
Re: Mouse click detection
Posted: Wed Jan 12, 2005 10:09 am
by PB
> unlike PB's screwed up Event system that gives me ONE event
Insulting PureBasic isn't the way to get help.
Posted: Wed Jan 12, 2005 6:03 pm
by TimmyTom
So, i am gathering there is no easy way to do this. A simple MouseDown() function ala Blitz isn't possible in PureBasic without going the difficult way. Pretty useless if you ask me. PureBasic is a nice language for simple apps, but that seems to be the extend of it.. pity.
Mind you, i wouldn't be using it if i hated it, i truly do like PureBasic, but to get anything done one seems to be forced to do massive workarounds for a lot of stuff.
Tim
Posted: Wed Jan 12, 2005 6:36 pm
by Paul
What version of Blitz are you comparing to? You didn't say if you are using a DirectX screen or a Window.
Anyway, can something like this not get you started??
Code: Select all
If OpenWindow(0,0,0,400,300,#PB_Window_SystemMenu,"")
Repeat
eventid=WindowEvent()
If eventid=#PB_Event_CloseWindow
quit=1
EndIf
If eventid=#WM_LBUTTONDOWN
buttondown=1
EndIf
If eventid=#WM_LBUTTONUP
buttondown=0
EndIf
If buttondown
Debug "Button Down"
EndIf
Delay(1)
Until quit
EndIf
Posted: Wed Jan 12, 2005 6:40 pm
by TimmyTom
Yeah, i am doing something like that now Paul, seems to be the easiest solution, even if i would rather not deal with window events at all.
I am actually using a windowed OpenGL screen in this case.
Tim
Posted: Wed Jan 12, 2005 6:41 pm
by Pupil
You can use 'GetAsyncKeyState()' to detect the state of a mouse button also... You should read up a bit on win API..
Posted: Wed Jan 12, 2005 6:43 pm
by TimmyTom
Really? hmm, my win32 api reference doesn't mention one word about that.. but, worthy of testing
Thanx
Tim
Posted: Wed Jan 12, 2005 6:50 pm
by Pupil
WIN API wrote:
The GetAsyncKeyState function works with mouse buttons. However, it checks on the state of the physical mouse buttons, not on the logical mouse buttons that the physical buttons are mapped to. For example, the call GetAsyncKeyState(VK_LBUTTON) always returns the state of the left physical mouse button, which may mapped to the left or right logical mouse button. You can determine the system's current mapping of physical mouse buttons to logical mouse buttons by calling
GetSystemMetrics(SM_SWAPBUTTON)
which returns TRUE if the mouse buttons have been swapped.
Posted: Wed Jan 12, 2005 6:54 pm
by TimmyTom
Yeah, works great! thanks for that.. guess i'll need to get another Win32 API reference, as this one stinks
Tim
Posted: Wed Jan 12, 2005 6:59 pm
by Paul
Code: Select all
If OpenWindow(0,0,0,400,300,#PB_Window_SystemMenu,"")
Repeat
If GetAsyncKeyState_(#VK_LBUTTON)
Debug "Mouse Click"
EndIf
eventid=WindowEvent()
If eventid=#PB_Event_CloseWindow
quit=1
EndIf
Delay(1)
Until quit
EndIf