string containing '@' passed to Fl_Table to display causes problems

21 views
Skip to first unread message

Roberto Panetta

unread,
Jun 6, 2024, 4:49:23 AMJun 6
to fltk.general
I see passing a string containing '@' to Fl_table to display display only the first part
More in details I keep values in a  std::vector<std::vector<std::string>> using .c_str() to make FLTK happy

You need to pass a double '@@' inside a string

As example passing 'r...@example.com' displays only 'rob', you need to pass 'rob@@example.com' to Fl_Table to have it displayed as 'r...@example.com'

I suppose because @ is used also for custom pics inside buttons .. and in general in widgets

Is there a way to disable this and have string displayed as passed, skipping having '@' used as a special char inside widgets text ?

Ian MacArthur

unread,
Jun 6, 2024, 6:10:50 AMJun 6
to fltk.general
There's some discussion of this in the docs., but the easy option is probably to crib from Greg's examples...



 

Greg Ercolano

unread,
Jun 6, 2024, 6:41:20 AMJun 6
to fltkg...@googlegroups.com

On 6/6/24 03:10, Ian MacArthur wrote:

On Thursday 6 June 2024 at 09:49:23 UTC+1 eclet... wrote:
[..]

Is there a way to disable this and have string displayed as passed, skipping having '@' used as a special char inside widgets text ?

There's some discussion of this in the docs., but the easy option is probably to crib from Greg's examples...


    Fl_Table itself doesn't draw strings; it depends what text drawing functions you call in the draw_cell() callback.

    Some fl_draw() text drawing methods use '@' symbols by default, some do not, and some offer a flag to control it.

    For instance, this form of fl_draw() has a "draw_symbols" flag at the end which, if disabled, will disable drawing @ symbols:
    void fl_draw(const char *str, int x, int y, int w, int h, Fl_Align align, Fl_Image *img, int draw_symbols)

    ..so that's probably the best route is to use the best fl_draw() method variation for what you're doing; the docs (link above) say:

    ".. The draw_symbols argument specifies whether or not to look for symbol names starting with the '@' character'"

    In cases where you might be stuck with @ symbols being on, you can prefix strings with @. to disable special '@' parsing for the rest of the string, e.g. "@.rob@example.com".

   

Roberto Panetta

unread,
Jun 6, 2024, 1:11:46 PMJun 6
to fltk.general
Yes absolutely easy
I changed:

fl_draw((*content).at(ROW,COL).c_str(), X+leftMargin,Y,W-leftMargin,H, FL_ALIGN_LEFT);

to:

fl_draw((*content).at(ROW,COL).c_str(), X+leftMargin,Y,W-leftMargin,H, FL_ALIGN_LEFT,0,0);

and it works perfectly

Thank you to pointing me to the right direction

My fault I didn't analyzed better fl_draw

Reply all
Reply to author
Forward
0 new messages