Editable SpinGadgets

Everything else that doesn't fall into one of the other PB categories.
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Editable SpinGadgets

Post by halo »

I found some code for editable spingadgets that worked fine. Then I put it in a DLL and including the spingadget source causes a 'userlib not found' error. Makes no sense.

Is there any easier way to make a spingadget where the value can be edited in text? This seems really ridiculous for such a simple task to be so complicated. Why doesn't PB just do this autmatically?!
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post by halo »

Okay, it can be boiled down to this. Fortunately, I can do without it, but the catch is that you CANNOT use this with a window callback function!!!

Code: Select all

Select WaitWindowEvent()
  Case #PB_Event_Gadget
    PROPERTIESCHANGED=1
    ;MessageRequester("","HI",0)
    If EventGadgetID()=GADGET0
      a$=GetGadgetText(GADGET0)
      a=Val(a$)
      b=GetGadgetState(GADGET0)
      If b<>a Or a$<>Str(a)
        If EventType()=#PB_EventType_Change Or EventType()=#PB_EventType_Focus Or EventType()=#PB_EventType_ReturnKey
         SetGadgetState(GADGET0,a)
         If Str(a)<>a$
            SetGadgetText(GADGET0,Str(a))
            SendMessage_(GadgetID(GADGET0),#em_setsel,0,-1)
            EndIf
          Else
          SetGadgetText(GADGET0,Str(b))
          SetGadgetState(GADGET0,b)
          EndIf
       EndIf
    EndIf
;  Default
;    MessageRequester("",Str(EventID),0)
  EndSelect
Post Reply