in derived class of Fl_Table_Row on callback of draw_cell changing value of Fl_Output but redrawing only happening on changing mouse focus

28 views
Skip to first unread message

Aditya Mudaliar

unread,
Oct 18, 2020, 2:59:20 PM10/18/20
to fltk.general
Hi
i am using Ubuntu 18.04.5 LTS using fltk version 1.3.5
i am trying to get data from a selected cell of Fl_Table_Row,btw i have stored the data in a map
trying to display the OrderId field in the Fl_Output* that is g_Fields.pOrderId
which is in draw_cell of class DemoTable
line no 222  in the attached file SendOrder.cpp
i am using the class from  Erico's Examples.
its being redrawn only after i change my mouse focus to it.
i have already tried 
g_Fields.pOrderId->redraw();
still it doesnt work
Kindly help


SendOrder.cpp

Greg Ercolano

unread,
Oct 18, 2020, 3:42:08 PM10/18/20
to fltkg...@googlegroups.com
You have to set the value of the Fl_Output in your table_cb().

Just add this to the bottom of table_cb():

// Set the "Orderid" output to the clicked on table row
string val = std::to_string(table->callback_row()); // int -> string
g_Fields.pOrderId->value(val.c_str()); // set string value

I'm assuming here the orderid == table row#.

If not, then use the callback_row() value to index the array
that has the orderid info.

Aditya Mudaliar

unread,
Oct 19, 2020, 11:48:09 AM10/19/20
to fltk.general
wow thanks alot its working,the only thing i also expected was to handle selection drag as well as i have set 
lpcDemotable->type(Fl_Table_Row::SELECT_SINGLE);
only a single row.is selected
the selection drag on the table doesnt call the table_cb method what might be the work around or way?

Greg Ercolano

unread,
Oct 19, 2020, 12:18:06 PM10/19/20
to fltkg...@googlegroups.com
On 2020-10-19 08:44, Aditya Mudaliar wrote:
> wow thanks alot its working,the only thing i also expected was to handle selection drag as well as i have set 
> lpcDemotable->type(Fl_Table_Row::SELECT_SINGLE);
> only a single row.is selected

Well yes, SELECT_SINGLE only allows a single row to be selected, hence the name.

If you want to select multiple rows, use type(Fl_Table_Row::SELECT_MULTI) instead.
https://www.fltk.org/doc-1.4/classFl__Table__Row.html#ad1acf911fc639c242d65ff7d5678146a

> the selection drag on the table doesnt call the table_cb method what might be the work around or way?

If you want to keep SELECT_SINGLE, but want to track a drag (FL_DRAG) without having
multiple items selected, you can overload the table's handle() method and track FL_DRAG
events, and then inquire the table for the currently selected item using any of e.g.

current_row() -- selection cursor's current row (-1 if none)
https://www.fltk.org/doc-1.4/classFl__Table.html#a298ac46626281813442cba3b5716b12b

row_selected() -- Checks to see if 'row' is selected.
https://www.fltk.org/doc-1.4/classFl__Table__Row.html#aff19cae2fe81ef59f47d2970f2275df5

is_selected() -- See if the cell at row r and column c is selected.
https://www.fltk.org/doc-1.4/classFl__Table.html#a7913a4f0c7db42374c1b17975a173916

Those are just some; there's others. Please see the docs for both public and protected methods
that your derived class can use to get information about the selection.
Reply all
Reply to author
Forward
0 new messages