Pressing enter in SpinGadget

Just starting out? Need help? Post your questions and find answers here.
paulr
User
User
Posts: 70
Joined: Sat Sep 27, 2003 2:53 pm

Pressing enter in SpinGadget

Post 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?
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: Pressing enter in SpinGadget

Post 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:
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Pressing enter in SpinGadget

Post by IdeasVacuum »

It possibly depends on the User's Windows Sounds settings.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Pressing enter in SpinGadget

Post 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
Egypt my love
paulr
User
User
Posts: 70
Joined: Sat Sep 27, 2003 2:53 pm

Re: Pressing enter in SpinGadget

Post 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.
Post Reply