B4J Question Shortcut key

elitevenkat

Active Member
Licensed User
Longtime User
I want to show _Save as text in a button control (actually the underscore should appear under the character "S" instead of preceding it. how to achieve it ?
 
Set the button text to "_Save"
then using javaobject set MnemonicParsing to true for the button

Code:
dim b as Button
...
b.initialize("but1")
b.text = "_Save"
asJO(b).RunMethod("setMnemonicParsing",array(true))
...
sub asJO(o as JavaObject) as JavaObject
return o
end sub
...
sub but1_Action
' now ALT+S will also call this routine as well as a click on the button
...
end sub
...
 
Upvote 0
Set the button text to "_Save"
then using javaobject set MnemonicParsing to true for the button

Code:
dim b as Button
...
b.initialize("but1")
b.text = "_Save"
asJO(b).RunMethod("setMnemonicParsing",array(true))
...
sub asJO(o as JavaObject) as JavaObject
return o
end sub
...
sub but1_Action
' now ALT+S will also call this routine as well as a click on the button
...
end sub
...

@Daestrum
Thanks for the code. It works. However the underscore character appears only if you press ALT once and remains after that forever. It does not appear automatically when the form is displayed.
How to make it appear without pressing ALT key?
 
Upvote 0
Try an invalidate to refresh the view
 
Upvote 0

Similar Threads

Replies
20
Views
44K
Replies
0
Views
5K
Replies
0
Views
428K
Back
Top