Fl_Tabs

52 views
Skip to first unread message

holm.h...@gmail.com

unread,
Apr 28, 2026, 2:38:44 AM (7 days ago) Apr 28
to fltk.general

Hello,
I just installed the new fltk version.

I have a issue with  Fl_Tabs. In the test/tabs.cxx file, I add:
{ Fl_Box* o = new Fl_Box(300, 35, 25, 25, "X");
      o->box(FL_UP_BOX);
 }
at line 261.  Just after Fl_Tabs ends.

this box is now ontop of the Fl_Tabs.
the box show initially, but will easily disapear when moving the mouse into the tab.

My problem is that I have a Fl_Tabs that will a window. I want to user the Fl_Box  to close the window.

How to fix this ?

Best regards
Håvard

Matthias Melcher

unread,
Apr 28, 2026, 6:33:32 AM (7 days ago) Apr 28
to fltk.general
holm.h...@gmail.com schrieb am Dienstag, 28. April 2026 um 08:38:44 UTC+2:

Hello,
I just installed the new fltk version.

1.4.5,  I assume
 
I have an issue with  Fl_Tabs. In the test/tabs.cxx file, I add:

{ Fl_Box* o = new Fl_Box(300, 35, 25, 25, "X");
      o->box(FL_UP_BOX);
 }
at line 261.  Just after Fl_Tabs ends.
  
this box is now ontop of the Fl_Tabs.
the box show initially, but will easily disapear when moving the mouse into the tab.

The area to the right of the tabs is reserved for further tabs that you may add. You can;t put a widget there. You can put close buttons on individual tabs, or you can use the close button of the window by using the window callback, or you can put your own close button somewhere else, but it can't overlap with Fl_Tabs.
 

Greg Ercolano

unread,
Apr 28, 2026, 12:55:32 PM (7 days ago) Apr 28
to fltkg...@googlegroups.com


On 4/27/26 23:38, holm.h...@gmail.com wrote:

Hello,
I just installed the new fltk version.

I have a issue with  Fl_Tabs. In the test/tabs.cxx file, I add:
{ Fl_Box* o = new Fl_Box(300, 35, 25, 25, "X");
      o->box(FL_UP_BOX);
 }
at line 261.  Just after Fl_Tabs ends.

this box is now ontop of the Fl_Tabs.

    That's not a good way to do it; you shouldn't put one widget "over"
    another unless it's a child.

    It seems like you're trying to do is make a tab called "x" so when it's clicked
    it closes the parent window.

    A good way to do that is to create a new tab group called "X", just like the other tabs,
    and set the cb_tabs_group() callback to detect when that tab is selected  and close the
    parent window by hide()ing it. The result will look the same:



    ..and the tab will look like the others, and will be keyboard navicable.
    See my suggested patch below for how that's done.

    For what you proposed, as a general rule you shouldn't position one widget "over" another. The only exception is if the widget is defined as a child of a parent group. So that isn't really allowed.

    Here's a patch to the tabs.cxx code that does what I suggested:


--- /usr/local/src/fltk-1.4.x.git/build/test/tabs.cxx    2025-11-17 14:02:05.810111969 -0800
+++ tabs.cxx    2026-04-28 09:43:09.461697129 -0700
@@ -1,10 +1,11 @@
-// generated by Fast Light User Interface Designer (fluid) version 1.0404
+// generated by Fast Light User Interface Designer (fluid) version 1.0500
 
 #include "tabs.h"
 
 Fl_Double_Window *foo_window=(Fl_Double_Window *)0;
 
 Fl_Tabs *tabs_group=(Fl_Tabs *)0;
+Fl_Group *x_grp = 0;    // new global group for the "x" tab button
 
 static void cb_tabs_group(Fl_Tabs* o, void*) {
   Fl_Widget *sel_tab = o->value();
@@ -13,6 +14,10 @@
   } else {
     printf("Callback called\n");
   }
+  // Close the parent window if the x_grp was selected
+  if (sel_tab == x_grp) {
+    o->parent()->hide();
+  }
 }
 
 static void cb_Label(Fl_Group* o, void*) {
@@ -254,6 +259,10 @@
         } // Fl_Window* o
         o->end();
       } // Fl_Group* o
+      { x_grp = new Fl_Group(10, 60, 315, 235, "X");
+        // Opening this group closes the parent window,
+        // so it will never be seen..
+      }
       // tabs_group->handle_overflow(Fl_Tabs::OVERFLOW_PULLDOWN);
       tabs_group->end();
       Fl_Group::current()->resizable(tabs_group);



holm.h...@gmail.com

unread,
Apr 29, 2026, 4:20:48 AM (6 days ago) Apr 29
to fltk.general

Hi,

This works, but ideally, I would like the "x" to be aligned to the right - a little away from the other tabs. Is that possible ?

Best regards
Håvard

Matthias Melcher

unread,
Apr 29, 2026, 5:35:52 AM (6 days ago) Apr 29
to fltk.general
FLTK does not support overlapping widgets. The area above the groups to the right of the tabs is considered part of Fl_Tabs and is used by Fl_Tabs if you have more individual tabs, filling up the space. So a close button at that location would overlap with Fl_Tabs and is not supported.

I marked the area that is managed by Fl_Tabs in green. You can't put anything else there.

7fTVF0TZD5h4SnaG.png





Greg Ercolano

unread,
Apr 29, 2026, 10:37:44 AM (6 days ago) Apr 29
to fltkg...@googlegroups.com


On 4/29/26 01:20, holm.h...@gmail.com wrote:

Hi,

This works, but ideally, I would like the "x" to be aligned to the right - a little away from the other tabs. Is that possible ?

    Hmm, no, I don't think you have much control over the position of the tabs.
    I think to get what you want, you'd have to subclass Fl_Tabs, or make a local copy of Fl_Tabs, rename it (e.g. My_Fl_Tabs) and then customize it.
Reply all
Reply to author
Forward
0 new messages