I want to have a control like the tabs in the Xojo IDE, where I can can respond to a click on a particular tab (note that I don’t need a tab panel, just a control). As in the IDE, each “tab” must have an X that, when clicked, closes that element. A segmented control would seem well suited for this, except there is no paint event, making drawing of the X difficult. I thought of using an array of canvases and emulating such a control myself, but it seems canvases can’t be created dynamically (or at least I couldn’t do it). What solutions are others using in this type of situation (this is for macOS only, if that makes a difference)?
https://github.com/alexrestrepo/RBCustomTabPanel
might need some updates but it can certainly be hand draw (which is what we do in the IDE so we can make it x-platform)
RBCustomTabPanel is really hard to beat, but it requires external images and isn’t HiDPI ready…
If you want to create the tabs using dynamically created canvases, take a look at control sets…
Based on Kuba Pawlak’s tutorials with list boxes, I was thinking about trying my hand at using a list box for a tab control (just because you can, means you should ) but this would still require doing custom drawing…
Thank you. RBCustomTabPanel is quite cool, but overkill for what I would like to do, and would take a lot of time to adapt (and it doesn’t like 64-bit, either). I thought I figured out how to dynamically create a new canvas from canvas control set, but I guess not. Here’s what I did:
- Add a canvas to a window (Canvas1) and make it a control set.
- In the Paint event
g.ForeColor = RGB(128, 128, 128)
g.DrawRect me.left, me.top, me.width, me.Height
- Add a window property, c As Canvas1.
- In code,
c = new canvas1
c.Index = 1
c.top = 100
c.left = 200
c.Height = 50
c.width = 50
c.Refresh
The canvas is created, .visible = true, the parent window is correct, the coordinates are correct, and the paint event fires, but I can’t see it. I’m sure it’s something dumb, but what am I missing?
The rectangle you’re drawing is not even on the canvas.
Try this:
g.DrawRect(0, 0, me.width, me.Height)
D’oh, of course! Thanks.
I use RBCustomTabPanel in my 64-bit application, can’t remember if I had to fix anything to get it to work though…
Have a look at my solution Trixi’s Tabsheets (http://www.mothsoftware.com/content/xojo/). I don’t think it would be hard to add a close box.