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 ?
 

Daestrum

Expert
Licensed User
Longtime User
Set the button text to "_Save"
then using javaobject set MnemonicParsing to true for the button

B4X:
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

elitevenkat

Active Member
Licensed User
Longtime User

@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

Cableguy

Expert
Licensed User
Longtime User
Try an invalidate to refresh the view
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…