making a toolbar visible

I have an app with a basic toolbar on top. I have added 4 buttons to the toolbar, but when I run the app in the IDE, the toolbar is a no show. I have tried to use toolbar.visible=true and toolbar. enabled=true, but both raise a “This item does not exist” error at compile time. A search of the forum conversations doesn’t show a problem like mine. The Xojo manuals do not mention how to make a toolbar visible either. Is this a case of RTFM properly idiot, or is there a known IDE issue?

Did you add the toolbar to the window?

Sure did. I also forgot to say that I was trying to make the toolbar visible in the form’s activate event just in case there was an issue with the form’s actual state.

In the IDE you dragged the Toolbar to the window? It should just automatically appear when you run your application…

Ok, so I dragged the toolbar icon from the library onto my window and nothing happens. The toolbar icon does nothing. Now I forget how I originally got the first toolbar onto my form. I have the feeling thatGreg O’Lone is going to join this conversation with “there is a bug in Xojo that relates to the toolbar…”

Under Windows the toolbar is somewhat strange. It is invisible and placed under the window menu. So icons and captions are simply stuck on top of the window area. If no button is added, the toolbar simply never shows …

I wonder if this applies to OSX as well. Michel, can you run that project I sent you to see if the toolbar appears.

You correctly dragged the Toolbar class into the project. Now you got to drag the class onto the window. Click on the class (tbDraw), and drag it over the window in the left pane (Main). It will create an instance of the toolbar in the windows controls called tbDraw1. That is the one you must address in your code :slight_smile:

Thanks Mr Boo.Some supporting Xojo documentation would have been splendid. In the mean time, I ditched the toolbar idea and went with a tabbed page with a bunch of bevel buttons. Call me pathetic, but the whole toolbar idea got a bit too cryptic and convoluted for me.

Whatever works for you :wink:

Chris, have you looked at the UserGuide-UserInferface pdf that Documentation folder with Xojo? Section 2.14 (starting on page 95) of that manual is all about Toolbars. Don’t expect to find a great deal of explanation and the likes if you are only referencing the Language Reference.

…and don’t overlook the value of examining the Examples. That’s where I get most of my questions answered (other than these forums). I just tear apart the examples to see how things are done. I find the manuals’ explanations easier to understand once I see how it all fits together.

Create the toolbar in code.
If your application evolves you will have to add buttons and/or make them invisible depending on user actions. If you shatter that code over your application it is very hard to change/fix things when necessary.

It is something to get accustomed to but I see a lot of value in it.

I use an InitToolbar function that does the whole toolbar management; adding buttons, menus, enabling/disabling, icons, captions.
This function gets called whenever something is in need of change.

I don’t have to look through other code parts, all is centralized in this function.

[quote=135710:@Alexander van der Linden]Create the toolbar in code.
[/quote]

how to create a new toolbar in code??? i am currently add the toolbar using the IDE by dragging it in the window

The toolbar does not “appear” until you have added some toolbar buttons to it… until then it appears as an icon at the BOTTOM of the IDE window where the form is shown

example for TOOLBAR1.OPEN

Dim temp As ToolButton
temp = New ToolButton
temp.Tag=i
temp.Caption= "New"
temp.name   = cmd_NEW
Me.append temp

[quote=377752:@Dave S]The toolbar does not “appear” until you have added some toolbar buttons to it… until then it appears as an icon at the BOTTOM of the IDE window where the form is shown

example for TOOLBAR1.OPEN

Dim temp As ToolButton temp = New ToolButton temp.Tag=i temp.Caption= "New" temp.name = cmd_NEW Me.append temp [/quote]

i know that… what i like to do is NOT having the empty toolbar at the bottom but adding in the toolbar with on open for the window