Mouse and Keyboard Events should be available for Windows!

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Mouse and Keyboard Events should be available for Windows!

Post by Mijikai »

Why are Mouse & Keyboard Events only available for Gadgets?

-> #PB_Event_Gadget / #PB_Event_SysTray

Why is it not available for a Window ?
This would help a lot for anything custom on the window.
Ex. it would allow a WindowedScreen with a mouse that is not captured!

I really dont understand this and im tired of coding workarounds!

It would be nice to get support for:

Code: Select all

  #PB_EventType_MouseEnter
  #PB_EventType_MouseLeave
  #PB_EventType_MouseMove
  #PB_EventType_MouseWheel
  #PB_EventType_LeftButtonDown
  #PB_EventType_LeftButtonUp
  #PB_EventType_LeftClick 
  #PB_EventType_RightClick
  #PB_EventType_LeftDoubleClick
  #PB_EventType_RightDoubleClick
  #PB_EventType_Focus
  #PB_EventType_LostFocus
Edit:
Added example code below.

Example (just like the CanvasGadget works):

Code: Select all

EnableExplicit

Procedure.i Example()
  Protected click.i
  If OpenWindow(0,0,0,320,200,#Null$,#PB_Window_SystemMenu|#PB_Window_WindowCentered)
    If CanvasGadget(0,0,0,WindowWidth(0),WindowHeight(0))
      Repeat
        Repeat
          Select WindowEvent()
            Case #PB_Event_Gadget
              Select EventType()
                Case #PB_EventType_LeftButtonDown 
                  click = #True
                Case #PB_EventType_LeftButtonUp
                  click = #False
              EndSelect
            Case #PB_Event_None
              Break
            Case #PB_Event_CloseWindow
              Break 2
          EndSelect
        ForEver
        If StartDrawing(CanvasOutput(0))
          Box(0,0,WindowWidth(0),WindowHeight(0),#Black)
          DrawText(0,0,"MOUSE: " + Str(WindowMouseX(0)) + " x " + Str(WindowMouseY(0)))
          DrawText(0,32,"LEFT MOUSE BUTTON DOWN: " + Str(click))
          StopDrawing()
        EndIf
      ForEver
    EndIf
    CloseWindow(0)  
  EndIf
EndProcedure

End Example()
Last edited by Mijikai on Sun Nov 17, 2024 1:31 am, edited 3 times in total.
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Mouse Events should be available for Windows !

Post by DarkDragon »

Mijikai wrote: Mon Nov 11, 2024 11:46 amEx. it would allow a WindowedScreen with a mouse that is not captured !
ReleaseMouse doesn't work?
bye,
Daniel
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: Mouse Events should be available for Windows !

Post by Mijikai »

DarkDragon wrote: Mon Nov 11, 2024 3:20 pm ReleaseMouse doesn't work?
No, thats not the same.

Added example code to the first post, that shows what Mouse Events should be possible with just a Window !
(or WindowedScreen for that matter)
Gérard
User
User
Posts: 48
Joined: Sat Oct 17, 2015 6:00 pm
Location: France
Contact:

Re: Mouse Events should be available for Windows!

Post by Gérard »

Code: Select all

  If OpenWindow(0,0,0,320,200,#Null$,#PB_Window_SystemMenu|#PB_Window_WindowCentered)
    Repeat
      Event=WaitWindowEvent(20)
      ;
      Select Event
        ;=== EVENTS SOURIS ===
        Case #WM_LBUTTONUP     : Debug "LEFT BUTTON UP"
        Case #WM_LBUTTONDOWN   : Debug "LEFT BUTTON DOWN"
        Case #WM_LBUTTONDBLCLK : Debug "LEFT BUTTON DBLCLK"
        Case #WM_RBUTTONUP     : Debug "RIGHT BUTTON UP"
        Case #WM_RBUTTONDOWN   : Debug "RIGHT BUTTON DOWN"
        Case #WM_RBUTTONDBLCLK : Debug "RIGHT BUTTON DBLCLK"
        ;=== EVENTS MENUS ===
        Case #PB_Event_Menu
        ;=== EVENTS GADGETS ===
        Case #PB_Event_Gadget
        ;=== EVENTS SYSTRAY ===
        Case #PB_Event_SysTray
        ;=== EVENTS WINDOWS ===
        Case #PB_Event_ActivateWindow
        Case #PB_Event_DeactivateWindow
        Case #PB_Event_MaximizeWindow
        Case #PB_Event_MinimizeWindow
        Case #PB_Event_RestoreWindow
        Case #PB_Event_CloseWindow : Break
       ;Case #PB_Event_...
      EndSelect
    ForEver
  EndIf
■ Win10 64-bit (Intel Celeron CPU N2920 @ 1.86GHz, 4,0GB RAM, Intel HD Graphics) & PB 6.00 LTS
■ Vivre et laisser vivre.
■ PureBasic pour le fun
■ cage sur le forum Français
■ Mes sites: http://pbcage.free.fr - http://yh.toolbox.free.fr
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: Mouse Events should be available for Windows!

Post by Mijikai »

Not a solution!
Anyway, thanks for adding more examples that illustarte why it is needed.
User avatar
mk-soft
Always Here
Always Here
Posts: 6205
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Mouse Events should be available for Windows!

Post by mk-soft »

With Windows, not all mouse events that are on gadgets also arrive at the parent window.

With an active screen, the mouse events for windows and gadgets are completely excluded and are only processed by OpenGL or DirectX. This is why there is also the MouseRelease function ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: Mouse Events should be available for Windows!

Post by Mijikai »

Graphical (windowed) applications can use Mouse Event messages.
The input does not need to processed by OpenGL or DX.
This enables the mouse to move freely around the Desktop and other Windows.
(My request is for Windows not Screens)
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Mouse Events should be available for Windows!

Post by DarkDragon »

Mijikai wrote: Mon Nov 11, 2024 7:45 pm Graphical (windowed) applications can use Mouse Event messages.
The input does not need to processed by OpenGL or DX.
This enables the mouse to move freely around the Desktop and other Windows.
(My request is for Windows not Screens)
ReleaseMouse also enables the mouse to move freely everywhere. That's why I asked. You repeatedly say it doesn't work. But then why no bug report?

Btw. OpenGL has no input processing at all. Everything is done via events there.

I agree though the events would be nice for the window itself, just I think the reason why you want it might be wrong due to a bug that happens on your computer.
bye,
Daniel
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: Mouse Events should be available for Windows!

Post by Mijikai »

Why are we going back to screens - its completely irrelevant.
(Screen Keyboard & Mouse stuff is fine)

Its about Window Mouse Events!
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: Mouse Events should be available for Windows!

Post by Bisonte »

Mijikai wrote: Mon Nov 11, 2024 11:46 am Why are Mouse Events only available for Gadgets?

-> #PB_Event_Gadget / #PB_Event_SysTray

Why is it not available for a Window ?
This would help a lot for anything custom on the window.
Ex. it would allow a WindowedScreen with a mouse that is not captured!

I really dont understand this and im tired of coding workarounds!

It would be nice to get support for:

Code: Select all

  #PB_EventType_MouseEnter
  #PB_EventType_MouseLeave
  #PB_EventType_MouseMove
  #PB_EventType_MouseWheel
  #PB_EventType_LeftButtonDown
  #PB_EventType_LeftButtonUp
  #PB_EventType_LeftClick 
  #PB_EventType_RightClick
  #PB_EventType_LeftDoubleClick
  #PB_EventType_RightDoubleClick
  #PB_EventType_Focus
  #PB_EventType_LostFocus
Mouse EventTypes for normal windows ... crossplatform ... YES!

+1 from me !
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
miso
Enthusiast
Enthusiast
Posts: 410
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: Mouse Events should be available for Windows!

Post by miso »

Also +1 from me.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 561
Joined: Tue Jan 04, 2011 6:21 pm

Re: Mouse Events should be available for Windows!

Post by SPH »

What does Fred say about it? :idea:

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: Mouse Events should be available for Windows!

Post by mestnyi »

+1
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: Mouse and Keyboard Events should be available for Windows!

Post by Mijikai »

Lets also make this request for Mouse & Keyboard events :)
Post Reply