Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
Dirk Geppert
 
Posts: 58
Joined: Fri Sep 22, 2017 7:02 am

StringGadget () EventTypes

by Dirk Geppert Thu Nov 09, 2017 12:01 pm

Hello Fred,

to finish an input in StringGadegt by pressing Enter, it would be nice if this would also support #PB_EventType_ReturnKey.

Ciao Dirk
User avatar
Peter
 
Posts: 482
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: StringGadget () EventTypes

by Peter Thu Nov 09, 2017 12:20 pm

Hello Dirk,

for this one we have the AddKeyboardShortcut()-Command

Code: Select all
Enumeration
 
  #sg1
  #sg2
  #sg3
 
  #ShortcutReturnEvent
 
EndEnumeration

Procedure MenuEvents()
 
  Select EventMenu()
    Case #ShortcutReturnEvent
      Select GetActiveGadget()
        Case #sg1
          Debug "ReturnKey on #sg1"
        Case #sg2
          Debug "ReturnKey on #sg2"
        Case #sg3
          Debug "ReturnKey on #sg3"
      EndSelect
  EndSelect
 
EndProcedure

OpenWindow(0, 0, 0, 322, 105, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(#sg1, 8,  10, 306, 20, "")
StringGadget(#sg2, 8,  35, 306, 20, "")
StringGadget(#sg3, 8,  60, 306, 20, "")

AddKeyboardShortcut(0, #PB_Shortcut_Return, #ShortcutReturnEvent)
BindEvent(#PB_Event_Menu, @MenuEvents())


Greetings ... Peter

Edit:

Alternatively, you can use the GadgetEventEx-Module (https://github.com/spiderbytes/GadgetEventEx)

Code: Select all
XIncludeFile "GadgetEventEx.sbi"

Enumeration
  #Window
  #StringGadget
EndEnumeration

Procedure KeyUpEvent(e)
 
  Protected Which
  ! v_which = v_e.which;
 
  If Which = #CR
    Debug "ReturnKey-Event from #StringGadget: " + EventGadget()
  EndIf
 
EndProcedure

OpenWindow(#Window, 0, 0, 300, 300, "GadgetEventExDemo", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(#StringGadget, 10, 10, 100, 20, "StringGadget")
GadgetEventEx::Bind(#StringGadget, @KeyUpEvent(), "keyup")
Dirk Geppert
 
Posts: 58
Joined: Fri Sep 22, 2017 7:02 am

Re: StringGadget () EventTypes

by Dirk Geppert Fri Nov 10, 2017 9:57 am

Thanks Peter!
Return to Feature Requests and Wishlists

Who is online

Users browsing this forum: No registered users and 1 guest