KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Button shortcut keys?

 
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic
View previous topic :: View next topic  
Author Message
jmuirh
KiXforms Novice
KiXforms Novice


Joined: 05 Aug 2008
Posts: 4

PostPosted: Tue Aug 05, 2008 6:21 am    Post subject: Button shortcut keys? Reply with quote

Hi,

New to KiXforms programming. Cool stuff indeed!

One question i can't seem to find an obvious answer to (and as a newbie, obvious is the only place I look. Smile )

Is there a way to define buttons with a shortcut keypress... for example, a "Quit" button where "Q" could be defined as a keypress in place of a mouse click with the cosmetics of the button's text as such: Quit

Possible?

Thanks,
John
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Tue Aug 05, 2008 3:10 pm    Post subject: Reply with quote

Not that it would be intrinsic... except, you can define one button in a form as default (It then reacts on ENTER key), but this holds some pitfalls which I won't explain in depth now...

Kixforms is somehow missing the .Shortcut property for Buttons/Toolbuttons since day 1.

Well, you can do a workaround with the Form.OnKeyDown event examining the resulting .KeyCode (setting .KeyPreview to 1 firsthand), but you will have two Problems with it:

1. You won't be able to underline single Characters in the TollButtons .Text
2. You won't be able to catch combinated Keypresses with .OnKeyDown

1st problem may be solved with images for the Toolbutton Geek
but the 2nd one is not so trivial. [edit... on second thought: shortcut keys on Buttons differ from the ones in MainMenus, eh? Laughing ]

Please give me feedback if you want to follow this painful path and I'll try to cobble together a sample tonight...

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
jmuirh
KiXforms Novice
KiXforms Novice


Joined: 05 Aug 2008
Posts: 4

PostPosted: Tue Aug 05, 2008 3:44 pm    Post subject: Reply with quote

Quote:
1. You won't be able to underline single Characters in the TollButtons .Text


Actually, i discovered with some experimentation that placing an "&" in the .Text string will underline a character in the button text... so visually it looks as it should.

Quote:
Please give me feedback if you want to follow this painful path and I'll try to cobble together a sample tonight...


Yes, please. If it's not too much effort, i would appreciate a sample. Smile

Thank you.

John
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Aug 05, 2008 3:52 pm    Post subject: Reply with quote

One can flag these "shortcut keys" by using the "&" symbol in the TEXT property. For example:

$Button.Text = "&Quit"

Where the Q will be underlined in this case. Have to be mindful of the FOCUS though. Here's a scriptlet:

Code:

Break On

$System = CreateObject("Kixtart.System")

$Form = $System.Form()

$OkButton = $Form.Button()
$OkButton.Text = "&OK"
$OkButton.OnClick = "OkButton_Click()"
$OkButton.Center

$QuitButton = $Form.Button()
$QuitButton.Text = "&Quit"
$QuitButton.OnClick = "QuitButton_Click()"
$QuitButton.Center
$QuitButton.Top = $OkButton.Bottom + 10

$Form.Center
$Form.Show

$OkButton.Focus

While $Form.Visible
 $= Execute($Form.DoEvents)
Loop

Exit 0

Function OkButton_Click()

 $=  $System.MessageBox.Show("OK Clicked!")

EndFunction

Function QuitButton_Click()

 $Form.Hide

EndFunction
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Tue Aug 05, 2008 4:24 pm    Post subject: Reply with quote

Wow, learned something (again) I had forgotten today...
Thanx!

Sample follows later tonight Smile

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group