EventGadget() = -1 when using default text in StringGadget()

Everything else that doesn't fall into one of the other PB categories.
User avatar
TI-994A
Addict
Addict
Posts: 2791
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: EventGadget() = -1 when using default text in StringGadg

Post by TI-994A »

Derren wrote:I guess the "correct" way would be...
Or, simply target the entire gadget range, as what your original example seems to require:

Code: Select all

Case #PB_Event_Gadget
  Select EventGadget()
    Case 0 To 6 
      Select EventType()
        ;... lots of redundant codes here
      EndSelect
  EndSelect
:)
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
mestnyi
Addict
Addict
Posts: 1114
Joined: Mon Nov 25, 2013 6:41 am

Re: EventGadget() = -1 when using default text in StringGadg

Post by mestnyi »

While WindowEvent() : Wend
http://www.purebasic.fr/english/viewtop ... ead#unread

Code: Select all

If OpenWindow(0, 0, 0, 322, 225, "StringGadget Flags", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  StringGadget(0, 8,  10, 306, 20, "Normal StringGadget...")
  StringGadget(1, 8,  35, 306, 20, "1234567", #PB_String_Numeric)
  StringGadget(2, 8,  60, 306, 20, "Read-only StringGadget", #PB_String_ReadOnly)
  StringGadget(3, 8,  85, 306, 20, "lowercase...", #PB_String_LowerCase)
  StringGadget(4, 8, 110, 306, 20, "uppercase...", #PB_String_UpperCase)
  StringGadget(5, 8, 140, 306, 20, "Borderless StringGadget", #PB_String_BorderLess)
  StringGadget(6, 8, 170, 306, 20, "Password", #PB_String_Password)
  
  While WindowEvent() : Wend
  
  Repeat
    event = WaitWindowEvent()
    If event = #PB_Event_Gadget
      Select EventType()
         Case #PB_EventType_Change
            ;If EventGadget()>-1
               SetGadgetColor(EventGadget(), #PB_Gadget_BackColor, RGB(255, 200, 200))
            ;EndIf 
        Case #PB_EventType_LostFocus
          SetGadgetColor(EventGadget(), #PB_Gadget_BackColor, RGB(255, 255, 255))
      EndSelect
    EndIf
  Until event = #PB_Event_CloseWindow
EndIf
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: EventGadget() = -1 when using default text in StringGadg

Post by uwekel »

mestnyi wrote: While WindowEvent() : Wend
I tried this as well on Windows, but got some trouble with window painting, e.g. corrupted drawings.
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
mestnyi
Addict
Addict
Posts: 1114
Joined: Mon Nov 25, 2013 6:41 am

Re: EventGadget() = -1 when using default text in StringGadg

Post by mestnyi »

Why?Why?Why? :evil: :evil: :evil: when you click on the gadget in no event # pb_event_gadget and Bindvent () is an event going on, if you click on the emptiness inside gadget (meaning where there is no text), then click event happens here and there

Code: Select all

Procedure Event_Gadget()
    Debug "down_and_up"
      Debug "-+-"
EndProcedure

If OpenWindow(0, 100, 100, 300, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 5, 5, 290, 90, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
  AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
  
  BindEvent(#PB_Event_Gadget,@Event_Gadget())
  Repeat
    Event = WaitWindowEvent()
    If Event = #PB_Event_Gadget
      Debug "up"
      Debug "--"
    EndIf
  Until Event = #PB_Event_CloseWindow
EndIf
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: EventGadget() = -1 when using default text in StringGadg

Post by Danilo »

mestnyi wrote:Why?Why?Why? :evil: :evil: :evil:
You need to check the event type. PureBasic's ListIconGadget supports the following event types in PB 5.2x LTS:

Code: Select all

eventType = EventType()
; #PB_EventType_LeftClick        : left click on an item, or a checkbox was checked/unchecked
; #PB_EventType_LeftDoubleClick
; #PB_EventType_RightClick
; #PB_EventType_RightDoubleClick
; #PB_EventType_Change           : the current item changed
; #PB_EventType_DragStart        : the user tried to start a Drag & Drop operation.
Is it really so difficult to understand that simple system, after so many month of using PB?
Post Reply