[XForms] Question #2: Relying on menu subitem IDs after fl_delete_menu_item().

Jens Thoms Toerring jt at toerring.de
Fri Jul 4 13:50:52 EDT 2008

To subscribers of the xforms list

Hi Jason,

> One problem that I found is fl_delete_menu_item refers to the item
> index, not the value. This can make deleting items pretty tricky. To
> that end I've added a function to go the other way, from value to
> item. It works for me although I may have missed some things

I don't think so. Your's is basically a new version of the
already existing (but only local to menu.c) val_to_index()

> (specifically, I'm not sure if the ISPUP thing is right -- and also,

If the menu gets created with the fl_set_menu_entries()
function instead of as many calls of fl_addto_menu() as
there are items the menu is just a normal popup (from
which no items can be removed and where no values can
be assigned differing from the index etc.) and in this
case ISPUP() returns true. So your use is exactly right.

> is the item index really 1-based?), 

Yes. Probably the original author got bored with hunting
for bugs due to a mising subtraction of 1 or the corres-
ponding addition in the right places. My preference would
be anyway to use always 0 based arrays, also in the puplic
interface, but I guess it's much too late for doing any-
thing about that now...

> I tried to make it the inverse of
> fl_get_menu_value. Note that if multiple items have the same value,
> this returns the first item with that value. Returns -1 if value is
> not found.

Yes, that's the problem with the values - they get set by
the user, so it can't be made sure that they are unique.

> === menu.c ===
> int
> fl_get_menu_item_from_value( FL_OBJECT * ob,
> 			     int         value )

I will add the function to the new release.

                         Best regards, Jens
  \   Jens Thoms Toerring  ________      jt at toerring.de
   \_______________________________      http://toerring.de
To unsubscribe, send any message to
xforms-leave at bob.usuhs.mil or see: 
List Archive: http://bob.usuhs.mil/pipermail/xforms and
Development: http://savannah.nongnu.org/files/?group=xforms

More information about the Xforms mailing list