>  Should I be using Action to detect is an existing item is selected?

  Yes. You use the callback parameters to identify the newly selected item.

action =  function(text, item, state)

  Check if state == 1, to identify if the item is being selected

> (does it fire if a new item is added?

  No

Best,
Scuri





Em seg, 14 de jan de 2019 às 23:12, Ranier VF <[email protected]>
escreveu:

> Hi,
> I'm using callback VALUECHANGED_CB with list control, to populate
> another list control, when user selects one item. Inside function, I use
> VALUE attribute to know what item was selected.
> But, my list controls don´t allow edition, or, EDITBOX=NO.
>
> If this can help you, I use too AttributeHandle to link one list control
> with another list control, in C:
> Ihandle * ih = IupGetAttributeHandle(list, "list_city_uid");
>
> ih will be populated according user selection.
>
> Best regards,
> Ranier Vilela
>
> ________________________________________
> De: [email protected] <[email protected]>
> Enviado: segunda-feira, 14 de janeiro de 2019 12:55
> Para: [email protected]
> Assunto: [Iup-users] Dropdown plus editbox -- how best to get value
>
> I have a list control (Place) with both dropdown and editbox true. The
> user can either select an existing value or enter a new one.  Using IUP 3.5
> with Lua under windows.
>
> If they select an existing value, I need to populate a second list control
> (Address) – also dropdown and editbox – with the known addresses for the
> selected Place.
>
> If they enter a new Place via the editbox, I need to eliminate duplicate
> spaces and check if it is still a new Place. If it’s not new, I need to
> select the ‘duplicate’ Place (the one they should have selected) and
> populate the Address list; if it is new, I need to update a lookup table
> and clear the Address list.
>
> I’m trying to determine the best call backs to use to implement this.
>
> Should I be using Action to detect is an existing item is selected? If I’m
> reading the documentation correctly, because it’s an editbox, Place.VALUE
> won’t tell me what the selected item is if it’s an existing item, but the
> text and parameters for the Action callback will?
>
> Or Valuechanged? Again, Place.VALUE won’t help for an existing item.
>
> Or should I be using a combination – if Action fires, then an existing
> item has been selected (does it fire if a new item is added?); and if
> Valuechanged fires, it’s a new item? Or might they both fire, in which case
> what would be the order.
>
> And if so, how do I define two callbacks within this (parameterised)
> structure:
>
>     function MakeList(options)
>        local l = iup.list{}
>         if options.callback ~= nil then
>             local callback = options.callback
>             local ebox = (options.editbox or "NO") == "YES"
>             if ebox then
>                 l = iup.list{valuechanged_cb = function(self) callback()
> end}
>             else
>                 l =iup.list{killfocus_cb = function(self) callback() end }
>             end
>         end
>         l.editbox = options.editbox or "NO"
>        l.dropdown=options.dropdown or "YES"
>        return l
>     end
>
>
>
>
>
>
>
>
> _______________________________________________
> Iup-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/iup-users
>
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to