Page 1 of 1

Pressing enter in SpinGadget

Posted: Thu Jun 11, 2020 10:58 am
by paulr
Hi, I've noticed pressing enter while editing the number in a SpinGadget triggers a system beep (Windows 10). Is there a way to prevent this and instead to trigger some action in the program?

Re: Pressing enter in SpinGadget

Posted: Thu Jun 11, 2020 11:06 am
by Marc56us
paulr wrote:Hi, I've noticed pressing enter while editing the number in a SpinGadget triggers a system beep (Windows 10). Is there a way to prevent this and instead to trigger some action in the program?
No beep for me, at least with the example in the doc?
A beep can occur if we exceed the defined values.
PS. Note that the mouse wheel can also change the value.

:wink:

Re: Pressing enter in SpinGadget

Posted: Thu Jun 11, 2020 11:43 am
by IdeasVacuum
It possibly depends on the User's Windows Sounds settings.

Re: Pressing enter in SpinGadget

Posted: Thu Jun 11, 2020 12:56 pm
by RASHAD
Hi

Code: Select all

If OpenWindow(0, 0, 0, 140, 70, "SpinGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SpinGadget(0, 10, 10, 65, 25, 0, 100,#PB_Spin_Numeric )
  TextGadget(1,10,40,60,25,"")
     
  SetGadgetState (0, 5) : SetGadgetText(0, "5")
  AddKeyboardShortcut(0, #PB_Shortcut_Return, 10)
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
        
      Case #PB_Event_Menu
        Select EventMenu()
          Case 10
            If GetActiveGadget() = 0
              SetActiveGadget(-1)
              SetGadgetText(1,GetGadgetText(0))
            EndIf
        EndSelect
    EndSelect
  Until Quit = 1
EndIf

Re: Pressing enter in SpinGadget

Posted: Thu Jun 11, 2020 2:37 pm
by paulr
The beep (or more of a windows 'bling') is definitely happening for me.

RASHAD, thanks for the suggestion, that works great in your example (and eliminates the pointless beep).

I've just expanded on it here to show it working on two independent spinners.

Code: Select all

If OpenWindow(0, 0, 0, 240, 70, "SpinGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SpinGadget(0, 10, 10, 65, 25, 0, 100,#PB_Spin_Numeric )
  TextGadget(1,10,40,60,25,"")
  SpinGadget(2, 110, 10, 65, 25, 0, 100,#PB_Spin_Numeric )
  TextGadget(3,110,40,60,25,"")
     
  SetGadgetState (0, 5) : SetGadgetText(0, "5")
  SetGadgetState (2, 5) : SetGadgetText(0, "5")
  
  AddKeyboardShortcut(0, #PB_Shortcut_Return, 10)
  Repeat
    e = WaitWindowEvent()
    Debug e
    Select e
      Case #PB_Event_CloseWindow
        Quit = 1
       
      Case #PB_Event_Menu
        Select EventMenu()
          Case 10
            If GetActiveGadget() = 0
              SetActiveGadget(-1)
              SetGadgetText(1,Str(Val(GetGadgetText(0))*2))
            ElseIf GetActiveGadget() = 2
              SetActiveGadget(-1)
              SetGadgetText(3,Str(Val(GetGadgetText(2))*2))
            EndIf
        EndSelect
    EndSelect
  Until Quit = 1
EndIf
Problem solved for me, thank you.