Discussion:
[Foxgui-users] how to format an FXString for a menu command
Julia Dudascik (Contractor)
2016-08-02 15:38:36 UTC
Permalink
I have a series of FXMenuCommands in my FXMenuPane. These menu commands
have accelerators associated with them. So when I display the menu command,
I want to display its accelerator. I use the FOX function setAccelText. The
problem I have is that the Menu commands consist of strings of different
lengths. So, as a result, my menu command accelerators do not line up, as
shown below:

Open File ... Ctrl O
Save and Exit Ctrl S

How do I get my accelerators to line up? I have tried to insert a \t and it
does not help. I have also tried inserting blank spaces into my menu
commands. This does not seem to work with FXString.


Please help.
Julia
Jeroen
2016-08-02 16:39:16 UTC
Permalink
On Tue, 2 Aug 2016 11:38:36 -0400
Post by Julia Dudascik (Contractor)
I have a series of FXMenuCommands in my FXMenuPane. These menu commands
have accelerators associated with them. So when I display the menu command,
I want to display its accelerator. I use the FOX function setAccelText. The
problem I have is that the Menu commands consist of strings of different
lengths. So, as a result, my menu command accelerators do not line up, as
Open File ... Ctrl O
Save and Exit Ctrl S
How do I get my accelerators to line up? I have tried to insert a \t and it
does not help. I have also tried inserting blank spaces into my menu
commands. This does not seem to work with FXString.
Normally, when setting up a menu command, you pass both label and accelerator
and maybe help-text on the constructor, as in:

new FXMenuCommand(filemenu,"&Open...\tCtl-O\tOpen document file.",openicon,this,ID_OPEN);

This will parse out the three pieces into the label "Open...", the accelerator
"Ctl-O" and the help text to be displayed in the status bar when mousing over
it "Open document file.".

The accelerator is also added to the top-level window's hot-key table; and
finally, the "&" in front of the "O" will add Alt-O to the menupane's accelerator
table, i.e. when its popped up Alt-O will invoke the menu.

The difference is, when invoking accelerator, the menu never needs to show up,
you go directly to the handler. With the hot-key, the menu needs to have been
brought up first (possibly, with another hot-key like Alt-F.

So, accelerators are app-wide, and you have only so many of them before you
run out of letters. But hot-keys are specific to menus or dialogs, and allow
you to re-use some letters depending on context.

As for layout, the FXMenuCommand will place the accelerator string on the
right hand-side, when layout is performed.

You may need to force a layout explicitly when changing the label or accel-
string after the menu has already been realized and brought up on the screen.

You may try POPUP_SHRINKWRAP to force recalculation when popup() is called.





-- JVZ


--
+----------------------------------------------------------------------------+
| Copyright (C) 11:20 08/ 2/2016 Jeroen van der Zijp. All Rights Reserved. |
+----------------------------------------------------------------------------+

------------------------------------------------------------------------------
Loading...