How to hide the entire menu bar in the Smart Client

I’d like to hide the entire menu bar from Servoy and just use the buttons and navigation that I created. I also would like to continue using Servoy’s shortcut keys such as Ctrl+N, Ctrl+E, etc.

I think we can do this. Where are these functionalities built in Servoy?

The setToolBarVisible(false) function is not enough. I need to hide the entire main menu bar (see image below).

[attachment=0]main_menu_bar_servoy_smart_client.GIF[/attachment]
BTW, I don’t want a Full Screen view, but I tried plugins.window.setFullScreen(true) and it does do the trick either. It still keeps the main menu bar.

This issue about the menu bar is not a problem in the Web Client –of course!

Thanks in advance for the tips!

JC

main_menu_bar_servoy_smart_client.GIF

If you only want to hide the menu bar, you can use:

plugins.window.getMenuBar().setVisible(false);

You can also remove it entirely (and replace with your own if you want):

plugins.window.getMenuBar().removeAllMenus();

Either way you will loose the standard shortcuts (but you can create you own using the plugins.window.createShortcut function)

Patrick, thank you very much.

What’s the difference between setVisible(false) and removeAllMenus() functions? Both of them remove the functionality of the standard shortcuts. I think that it’d be a good idea that the setVisible(false) function contains a parameter that allows us to keep the standard shortcuts if we favor so.

Could it be just better if I hide some of the menu items? Is it possible? For instance, I’d rather just show the “File” and “Select” menus but hide all the others. For instance, I have entire forms explaining data entries, exports and content items of the solution. Servoy’s help is actually a distraction. I need the File menu because of the exports that some of my users do, etc.

I any case, if I create my own shortcuts, how do I link those to the properties/commands of a form? Using the standard shortcut is easy because of the properties/commands in the UI. What if I can’t access those standard shortcuts?

Since I just want the Properties/Commands and shortcuts of the Servoy’s “File” and “Select” menus, I hided the other menu items. For the record and benefit of the Forum’s users, I resolved the issue in this way - I added the following lines in my start method:

	plugins.window.setStatusBarVisible(true);
	plugins.window.setToolBarVisible(false);
	//no need for plugins.window.getMenuBar().setVisible(false); 
	plugins.window.getMenuBar().removeMenu(1,2,4,5,6);

Now I get the following message “A _menu with index 5 doesn’t exist.”

[attachment=0]error_menu_index_number.GIF[/attachment]
When I trigger the client from Servoy Developer it works fine. The problem is in the thin client (smart client) running on the Server.

Am I doing something wrong in the line below?

plugins.window.getMenuBar().removeMenu(1,2,4,5,6);

Note: Both, Server and Developer are Servoy version 5.1.2 -build 959. Both installation on Windows, Server 2003 and Windows 7 respectively.

Guys, thanks all for helping with this. JC

Hi Carlos,

The removal of the menus is not atomical (it’s not done in one go, but menu by menu: think that it is really calling removeMenu(1) then removeMenu(2) etc.) meaning that between the time that the menu with index 1 has been removed and the time you remove the menu with index 5, it might be that the overall index has changed.

so when you remove menu 1, menu 2 is now menu 1, remove menu 2 might remove the old menu 3, etc…
So I would say that the fact that it works in developer was pure chance.

So, to be on the safe side, I would do it in reverse, like this:
plugins.window.getMenuBar().removeMenu(6,5,4,2,1);
This should work.

To Servoy: perhaps the indexes should be cached to perform that safely in the right order?

ptalbot:
Hi Carlos,
So, to be on the safe side, I would do it in reverse, like this:

plugins.window.getMenuBar().removeMenu(6,5,4,2,1);

Brilliant! Thanks.

Could it be working in developer because the indexes are somehow cached?

jcarlos:

ptalbot:
Hi Carlos,
So, to be on the safe side, I would do it in reverse, like this:

plugins.window.getMenuBar().removeMenu(6,5,4,2,1);

Brilliant! Thanks.

Could it be working in developer because the indexes are somehow cached?

The same code in the window.jar plugin is running in developer and server, so it is rather a threading/sync issue in Swing.

Servoy: Perhaps the easiest way would be to systematically sort the list of index in reverse order in the plugin?

yes this:

plugins.window.getMenuBar().removeMenu(1,2,4,5,6);

should just work.
can somebody make a case?

jcompagner:
yes this:

plugins.window.getMenuBar().removeMenu(1,2,4,5,6);

should just work.
can somebody make a case?

I will make a case, with a patch for this.

ptalbot:
I will make a case, with a patch for this.

Excellent!

Just for the record (and for those using a version that will not get the fixed or patch Servoy): the reverse mode (that Patrick suggested) is working fine!

plugins.window.getMenuBar().removeMenu(6,5,4,2,1);

Read Patrick’s explanation above.

Just to check: is this issue fixed yet in v.5.2.2?

I implemented some code using index with ascending numbers.
In developer this runs fine, but as soon as I deployed the solution to our production server I ran into a lot of errors.

Using the code with removing menuitems in reverse order works fine as described by Johan.

what kind of errors?

jcompagner:
what kind of errors?

Simular to the one jcarlos posted earlier in this thread, only this time for the menuitems…

if you still getting index errors and you already do it in reverse you really should check if you can remove them anyway
maybe that client doesnt have them at the first place.

No Johan, that’s not the case:

mboegem:
Using the code with removing menuitems in reverse order works fine as described by Johan.

yes but do you check if you can do it
before calling “plugins.window.getMenuBar().removeMenu(6,5,4,2,1);” ???

jcompagner:
yes but do you check if you can do it
before calling “plugins.window.getMenuBar().removeMenu(6,5,4,2,1);” ???

for the menu’s: yes
for the menuitems: no

but I can’t see where you’re heading.
Problem is that removeItem(0,1,2,4,5,6,7) fails and removeItem(7,6,5,4,2,1,0) doesn’t. (this is for the file menu (index 0))
Apart from all kinds of checks: at this point (right after firing a client) the menu’s are untouched, meaning that the items are really there. (proofed by the fact that the reverse order works)
What my initial point was: in developer removeItem(0,1,2,4,5,6,7) works fine, in normal smart client it doesn’t… So: why do they behave differently?

oh ok, so you are not doing the reverse order?
But i am looking at the code:

if (index.length > 1)
{
Arrays.sort(index, new DescendingNumberComparator());
}

and we already sort it first before doing the remove…

So i dont know what goes wrong then,

But removing all menu’s shouldnt be done like this anyway thats way more like:

while(menu.size() > 0) menu.remove(0)

I have several issues with the window plugin of Servoy 5.2.7 on Mac.
I’m using the laf.jar plugin to set the Metal LaF. In combination with that I always get a grey smart client window and an empty menue bar in developer if I set plugins.window.getMenuBar().setVisible(true). The Menues are activ when I slide with the mousecursor over the menuebar, but the menues (-names) itself are not displayed. Also the elements on a form in the smart client dev. getting only displayed when I slide with the mousecursor over the window. This effect is not if I set plugins.window.getMenuBar().setVisible(false) and/or set to the default LaF!? Do I launch the smart client from the Servoy application_server I don’t have that issues.

For a customers solution I would like to set the Metal LaF, but copy and paste from/to textfield by key shortcut is only working when the Edit menue is enabled and visible. To get this working and displaying the menues Edit and Help (it’s only working in smart client app server and not in sc dev.!) I have set

plugins.window.getMenuBar().removeMenu(5,4,3,2,0);
plugins.window.getMenuBar().validate();

in my onOpenSolution function. plugins.window.getMenuBar().removeMenu(0,2,3,4,5) is not working!