Missed #PB_EventType_ReturnKey

Share your advanced PureBasic knowledge/code with the community.
User avatar
mk-soft
Always Here
Always Here
Posts: 5386
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Missed #PB_EventType_ReturnKey

Post by mk-soft »

For many examples from PureBasic Forum 8)

Code: Select all

CompilerIf #PB_Compiler_Version >= 572
  #PB_EventType_ReturnKey = $501 ; SDK Event.h
CompilerEndIf
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
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Missed #PB_EventType_ReturnKey

Post by RSBasic »

Thank you. I needed this code now after updating a project to the latest PB version.
Image
Image
User avatar
jacdelad
Addict
Addict
Posts: 1473
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Missed #PB_EventType_ReturnKey

Post by jacdelad »

?

Google tells me this was a constant once and isn't anymore. Was it reintroduced? Do all gadget support it?
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
mk-soft
Always Here
Always Here
Posts: 5386
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Missed #PB_EventType_ReturnKey

Post by mk-soft »

The event type was supported in the past (pb v5.2).
But it was then also used as a help event constante by others later on.

Example from viewtopic.php?t=73820

Code: Select all

;-TOP

; ----

CompilerIf #PB_Compiler_Version >= 572
  #PB_EventType_ReturnKey = $501 ; SDK Event.h
CompilerEndIf

#MenuEvent_ReturnKey = 1000

Procedure DoEventGadgetType()
  Protected gadget = EventGadget()
  If IsGadget(gadget)
    Select GadgetType(gadget)
      Case #PB_GadgetType_String
        Select EventType()
          Case #PB_EventType_Focus
            AddKeyboardShortcut(0, #PB_Shortcut_Return, #MenuEvent_ReturnKey)
          Case #PB_EventType_LostFocus
            RemoveKeyboardShortcut(0, #PB_Shortcut_Return)
        EndSelect
    EndSelect
  EndIf
EndProcedure

Procedure DoEventReturnKey()
  PostEvent(#PB_Event_Gadget, GetActiveWindow(), GetActiveGadget(), #PB_EventType_ReturnKey)
EndProcedure

; ----

If OpenWindow(0, 0, 0, 400, 300, "StringGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  StringGadget(0, 10, 10, 380, 30, "StringGadget 1")
  StringGadget(1, 10, 50, 380, 30, "StringGadget 2")
  EditorGadget(2, 10, 90, 380, 190)
  
  CreateMenu(0, WindowID(0))
  BindEvent(#PB_Event_Gadget, @DoEventGadgetType())
  BindMenuEvent(0, #MenuEvent_ReturnKey, @DoEventReturnKey())
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Break
        
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0
            Select EventType()
              Case #PB_EventType_ReturnKey
                Debug "Return Gadget 0"
                SetActiveGadget(1)
            EndSelect
            
          Case 1
            Select EventType()
              Case #PB_EventType_ReturnKey
                Debug "Return Gadget 1"
                SetActiveGadget(2)
            EndSelect
            
        EndSelect
        
    EndSelect
  ForEver
  
EndIf
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
Post Reply