ezequiel garcia wrote:
> Hello FLTK users :)
> I have the following doubt.
> 
> In the example code:
> 
> Fl_Choice* choice = new Fl_Choice( /*something*/ );
> int a = choice->size();
> 
> // Now a == 0 as it should
> 
> choice->add("HELLO");
> 
> a = choice->size();
> 
> // Now a == 2, but I expected to be == 1.
> 
> So, how can it be that the size of the widget grows from nil to 2?
> 
> Any help will be appreciated :)

Subtract 1, and you're okay. ;-)

It's all documented (this is from FLTK 1.3):

"int Fl_Menu_::size ( )  const

This returns the number of Fl_Menu_Item structures that make up the 
menu, correctly counting submenus.

This includes the "terminator" item at the end.

To copy a menu array you need to copy size()*sizeof(Fl_Menu_Item) bytes. 
If the menu is NULL this returns zero (an empty menu will return 1)."

The same is true for FLTK 1.1, but you must look up the docs in 
Fl_Menu_::size()

http://www.fltk.org/doc-1.1/Fl_Menu_.html#Fl_Menu_.size

Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to