Page 2 of 2

Posted: Mon Dec 10, 2007 8:01 pm
by Berikco
blueznl wrote:I'd settle for just a simple mousebutton() but I'm not that demanding... today.
and tomorow? :)

Posted: Mon Dec 10, 2007 8:07 pm
by blueznl
Fine too. But no later. (And don't say tomorrow tomorrow, as tomorrow is today... euh...)

Posted: Mon Dec 10, 2007 8:15 pm
by Rook Zimbabwe
Is it tomorrow yet?

I cannot strongly enough urge the ability to return the mousebutton... and mousebuttonup values...

I think they could work similar in Windows and Linux... and on Mac with a 2 or three button mouse like I have seen for the more serious G5 units...

Maybe PB should forget legacy Mac code and look forward like Unlce Steve did? 8)

Posted: Mon Jul 21, 2008 8:32 pm
by tinman
I know this is an old thread, but is there anything happening on this front? I'd love native events for mouse handling, and events for keyboard as well (key down / key up - shortcuts just don't cut it in all cases ;).

At the moment I've got the choice of using:

1) the Windows API. Fine, but I'll never get it working on Linux or Mac, as I have no knowledge/experience there.

2) 2D games libraries, which you are recommended not to use.

..mousebutton

Posted: Thu Jul 23, 2009 6:26 pm
by kepu
:D
Anyway... Thanks 'Berikco' for your code
It seams to work fine without any crashes for me in both, Linux and Vista.

..
Of course 'for newbies like me' , the code needs be update like:

Code: Select all

OpenWindow(0, 0, 0, 300, 200,"Test", #PB_Window_SystemMenu)
         ;OpenWindow(0, 0, 0, 300, 200, #PB_Window_SystemMenu, "Test")

hWnd = WindowID(0)   ;hWnd = WindowID()

UseGadgetList(WindowID(0))      ;CreateGadgetList(WindowID(0))



Posted: Thu Jul 23, 2009 10:05 pm
by blueznl
This has been posted also a zillion times, I guess, but it may be of use to someone:

Code: Select all

Procedure.i x_leftmousebutton()                                                              ; return current state of left mousebutton
  ;
  ; retval: #True  - mouse button down
  ;         #False - mouse button up
  ;
  ; notes:
  ;
  ; - does not use events!
  ; - use #wm_lbuttonup and #wm_lbuttondown for event based handling
  ;
  If GetSystemMetrics_(#SM_SWAPBUTTON) = 0
    ProcedureReturn x_bool(GetAsyncKeyState_(#VK_LBUTTON))
  Else
    ProcedureReturn x_bool(GetAsyncKeyState_(#VK_RBUTTON))
  EndIf
EndProcedure

Procedure.i x_rightmousebutton()                                                             ; return current state of right mousebutton
  ;
  ; notes:
  ;
  ; - does not use events!
  ; - use #wm_lbuttonup and #wm_lbuttondown for event based handling
  ;
  If GetSystemMetrics_(#SM_SWAPBUTTON) = 0
    ProcedureReturn x_bool(GetAsyncKeyState_(#VK_RBUTTON))
  Else
    ProcedureReturn x_bool(GetAsyncKeyState_(#VK_LBUTTON))
  EndIf
EndProcedure

Procedure.i x_mousewheel(mode.i)                                                             ; returns number of lines up / down upon using the scrollwheel after a #WM_MOUSEWHEEL event
  Protected d.i
  ;
  ; *** returns number of lines up / down upon using the scrollwheel after a #WM_MOUSEWHEEL event
  ;
  ; in:     mode.i = 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