Why not a windowmousebutton command?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
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 BalrogSoft.


Hi...

Im writting a 3d editor for my 3d engine, and i need a command to read the mouse button on a window, but mouse library is only for screens, and EventType() command is only for gadgets, why not a WindowMouseButton, to know if the mouse button is pushed on a window, without gadgets and windowed screens.

Bye Balrog Soft

Balrog Soft
Amiga and PC Coder
http://www.balrogsoftware.com
[url]mailto:balrog@balrogsoftware.com[/url]
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 plouf.

mousebutton() from mouse libary isnt work for your project ?

Christos
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 BalrogSoft.
mousebutton() from mouse libary isnt work for your project ?

Christos
Mousebutton is for screens, and not windows, for this reason exists WindowMouseX() and WindowMouseY(), but not WindowMouseButton()....

Balrog Soft
Amiga and PC Coder
http://www.balrogsoftware.com
[url]mailto:balrog@balrogsoftware.com[/url]
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 Pupil.
Mousebutton is for screens, and not windows, for this reason exists WindowMouseX() and WindowMouseY(), but not WindowMouseButton()....
Why not try the win constants #WM_LBUTTONDOWN, #WM_LBUTTONUP, #WM_RBUTTONDOWN, #WM_RBUTTONUP in your event-loop, i think this would work...

Code: Select all

event.l = WaitWindowEvent()
Select event
  Case #WM_LBUTTONDOWN
    ;do something
  ...
EndSelect
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 BalrogSoft.
Mousebutton is for screens, and not windows, for this reason exists WindowMouseX() and WindowMouseY(), but not WindowMouseButton()....
Why not try the win constants #WM_LBUTTONDOWN, #WM_LBUTTONUP, #WM_RBUTTONDOWN, #WM_RBUTTONUP in your event-loop, i think this would work...

Code: Select all

event.l = WaitWindowEvent()
Select event
  Case #WM_LBUTTONDOWN
    ;do something
  ...
EndSelect
I tryed all this, and dont work...

Bye, Balrog Soft.

Balrog Soft
Amiga and PC Coder
http://www.balrogsoftware.com
[url]mailto:balrog@balrogsoftware.com[/url]
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.

> > Why not try the win constants #WM_LBUTTONDOWN [snip]
>
> I tryed all this, and dont work...

Note: This tip is for Windows only (not Amiga/Linux). And I suspect there's a
better way to do it that perhaps you're overlooking, but without your entire
source it's too hard to tell.

At the start of your app, before its main loop:

Code: Select all

GetAsyncKeyState_(#VK_LBUTTON) ; To clear the LMB before use.
Then, during your main loop:

Code: Select all

If GetAsyncKeyState_(#VK_LBUTTON)=-32767 ; LMB clicked!
  ; Do whatever.
EndIf
Same for #VK_RBUTTON and #VK_MBUTTON.


PB - Registered PureBasic Coder

Edited by - PB on 27 July 2002 00:29:07
Post Reply