DesktopToolbar

Hi everyone,
As I aways state, hobby programmer here. Looking for some assistance please.

I like to try and experiment a bit and am trying to implement the Toolbar project item. Double clicking it adds it to the project but not the window. I can see how to add buttons etc to the toolbar but cannot figure out how to make it appear on the window.

As so often happens, right clicking brings up nothing in help and there are no examples or YouTube vids that I can find (not obvious anyway). I can find it in the Documentation off the intro screen but, for a beginner/hobbiest, many times these are obscure and don’t help much (well, for me anyway), and I think are written for pros. (Makes it hard to learn tho).

Anyway, some starting hints/directions would be VERY much appreciated.

Thanks,
Barry

Hi Barry,

Assuming you already have your DesktopToolbar appearing in the Xojo IDE Navigator on the left-hand side (where you have added buttons, icons, captions, etc.).

You then display the Window you wish to add the toolbar to (you should see the “layout designer”).

Drag the toolbar from the left Navigator to the Window layout.

If successful, your toolbar should now appear across the bottom of the “Layout Designer” in a shaded band as an icon. The toolbar should also appear, I think, as a “Control” of the Window in the Navigator. Click the control version of the toolbar to enable editing any necessary properties.

I know it seems odd, but the toolbar does not appear graphically placed on the window, just in the shaded band across the bottom. You can however, if you need to make further changes to the toolbar (after dragging it to the Window), from it’s original location in the Navigator.

I think Xojo does it this way, because the idea of combining the toolbar designer and the window layout designer into one view would be too complicated.

I hope that helps.

1 Like

Thanks Scott, that’s great. Gives me the starting point I needed. If only there was simple instructions like this in the docs somewhere!

Barry

1 Like

You’re welcome Barry.

Maybe mark my post as the “answer”, to make it easier for the next person :nerd_face:

Thanks

Sure, but just before that, can I push you for 1 more bit of info please.

Now that I’ve added the toolbar, I can add an event for pushing the buttons and respond accordingly to the item passed in. That works ok for buttons but does not recognize if it is one of the list controls. How are they recognized?

I’m typing this away from my computer so I hope it makes sense.

Barry

Are you referring to a DropDownMenu on the Toolbar?

If so, you’ll need a MenuItemSelected event. If you want to see how its done and/or if people don’t answer quick enough here for you, there’s a few toolbar examples included with Xojo, if you Select File>New Project>Examples>Desktop>Controls>Toolbar the best starter one is ToolbarExample.xojo_binary_project.

1 Like

Hi Julian, speed of replied is absolutely not an issue. Thanks for that, I’ll give it a try. Often I just need the starting points and then with the docs I can delve into the rest.

I know you guys are pros but one of the good things about being a hobbiest is the detective work to get stuff going. The thrill of the chase :slight_smile:

Thanks again

We have all been there. And had the same fun.

2 Likes

my attempt to create a toolbar
with your own canvas elements can be used anywhere
the menus are placed

https://www.dropbox.com/sh/5o7avvoi42hhtx1/AADcXxQt36TqFpx-VC1yY7Hza?dl=1

Thanks everybody, you never fail :blush:

Barry

You know Julian, I looked through the examples and for some reason just never saw that group titled “Toolbar”!!

2 Likes

Hey guys,
Just a follow up thought, and for my education, this control first goes into the “general” contents section of the app. You then drag it onto the window you want it on where it is moved into the controls section of that window and you then work with it like any other (with it’s own individual methods, events etc).

My question is, is there a technical reason for the messing around with the first steps or could it have just been put straight onto the window like any other item had they wanted to. Seems like an extra (non-intuitive for a beginner) step. But, happy to be informed if there is a reason for it.

Barry

Like any control or project item in the library, just drag it from there onto the window in the IDE.

Thanks Tim, I didn’t realise that. I thought it had to go through the 2 steps I mentioned. I do note tho that it only places a “copy” on the window and the original stays in Contents. It is from here that any buttons, lists etc are added. Is that correct? I don’t understand why, but that’s cool, as long as I know where everything is.

Thanks

I’d say the reverse. The original has been created on the window, what is in the Contents is a handy reference like the contents of a book.

I’m not sure what Tim is referring to, but you can’t add a Toolbar directly to a Window without first adding it to the Project on the Navigator. It’s done this way because much like a MenuBar, the same Toolbar can exist on multiple windows so you create it once, then drag it onto the windows you want to use it on, then if you decide you need to make a change, you change it in one place and it changes on all the windows.

If you haven’t found this already, you can read more about it here https://documentation.xojo.com/topics/user_interface/desktop/desktop_controls/toolbar.html and there’s a few (now outdated, but generally informative) videos talking you through things.

1 Like

Thanks everyone for your help. Gives me a start and resources to now have a play.

Barry