Page 1 of 1

Spin Gadget (und ein Hinweiß für das Help-File

Posted: Sun Jun 15, 2003 1:51 pm
by GPI
Das Spin-Gadget enthält ja sowohl ein Text als auch einen (unsichbaren) Wert und das macht die Handharbung etwas schwieriger. Das Beispiel in der deutsch Anleitung ist nicht so gut:
A) Eingaben in Text-Bereich werden ignoriert
B) Mich stört das zusätzliche eventwindow() gewaltig...

Hier meine Lösung

Code: Select all

If OpenWindow(0,0,0,140,70,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"SpinGadget") And CreateGadgetList(WindowID(0)) 
    SpinGadget     (0,20,20,100,25,0,1000) 
    SetGadgetState (0,5) : SetGadgetText(0,"5")   ; Anfangswert festlegen 
    Repeat 
      ev.l = WaitWindowEvent() 
      If ev=#pb_event_gadget
        If EventGadgetID() = 0 
          If GetGadgetState(0)<>Val(GetGadgetText(0)) ; hat sich was geändert?
            If EventType()=#pb_eventtype_change ; = Eingabe in Textfeld
              SetGadgetState(0,Val(GetGadgetText(0)))
            Else
              SetGadgetText(0,Str(GetGadgetState(0)))
            EndIf
          EndIf
        EndIf
      EndIf 
    Until ev.l = #PB_Event_CloseWindow 
  EndIf 
p.s.: Man muß nicht unbedingt die Ziffern in Text-Feld schreiben, man kann da auch zwischen verschieden Wörtern umschalten...

Posted: Sun Jun 15, 2003 2:45 pm
by Thorsten
Hey GPI :D Wrong forum? :wink:

Posted: Sun Jun 15, 2003 3:46 pm
by GPI
Ah, Yes, complete wrong forum.

OK: Here a little translation of the text above:
In the german manual is a example of a spin-gadget, but there are two problems:
a) the example don't react, when i write text in the textbox of the spin
b) it used a windowevent() to throw a message away.

My Example above, shoes how the spin-gadget can handle correct, so that the user can type a value in the text box and can use the arrow buttons.

GPI

Posted: Sun Jun 15, 2003 10:16 pm
by Andre
Hey GPI, thanks for your suggestions. They are noticed, even when they are in german..... :lol: :lol: :lol:

Posted: Mon Jun 16, 2003 2:08 pm
by ebs
GPI,

Nice tip! It might be good to check if something other than a number is typed into the SpinGadget. That way, you can keep the value unchanged, instead of setting it to zero (Val() of a non-numeric = 0).

Thanks,
Eric