Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » How to add accelerator keys to menus
How to add accelerator keys to menus [message #27045] Tue, 22 June 2010 22:38 Go to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Hi,

I am unable to find this topic covered in the manuals. Is there any place in the web supplied information where this topic is explained?

I would appreciate a quick explanation about the subject.

Many thanks.
Re: How to add accelerator keys to menus [message #27056 is a reply to message #27045] Wed, 23 June 2010 15:33 Go to previous messageGo to next message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
Item::Key() is for that. Bar::Add() return a reference to Item. Here is an example.
bar.Add("Quit", THISBACK(Quit)).Key(K_CTRL | K_Q);


Andrei
Re: How to add accelerator keys to menus [message #27057 is a reply to message #27056] Wed, 23 June 2010 16:22 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
A better way is to use a .key file where you define your keys.

Then you can use the shortcut in multiple places with one definition. As a bonus there is a key editing dialog (for the user) that you can use very easily:

The reference project called AK shows this.
Re: How to add accelerator keys to menus [message #27108 is a reply to message #27057] Fri, 25 June 2010 16:25 Go to previous messageGo to next message
281264 is currently offline  281264
Messages: 270
Registered: June 2010
Location: Spain
Experienced Member
Thanks. How can a key file be generated and used?
Re: How to add accelerator keys to menus [message #27114 is a reply to message #27108] Fri, 25 June 2010 23:03 Go to previous messageGo to next message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
Hi,
You write the file by hand. I think AK example explain very clear how to use it. Add it to your project, then define KEYFILE macro to *.key file, include key_*.* based on location (header or source). KEYGROUPNAME is to separate key definitions in dialog where you change key bindings.

Andrei
Re: How to add accelerator keys to menus [message #35639 is a reply to message #27056] Fri, 09 March 2012 09:57 Go to previous messageGo to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

andrei_natanael wrote on Wed, 23 June 2010 15:33

Item::Key() is for that. Bar::Add() return a reference to Item. Here is an example.
bar.Add("Quit", THISBACK(Quit)).Key(K_CTRL | K_Q);


Yes, this works well !

But this way, I can have the SHIFT+CTRL combination, but others like CTRL+ALT or SHIFT+ALT give a complilation error :

Quote:

main.cpp:124: error: ‘K_CTRL_ALT_E’ was not declared in this scope


What is wrong ? Is there a simple way (without .key file) to have this working ?

Re: How to add accelerator keys to menus [message #35978 is a reply to message #35639] Fri, 13 April 2012 04:21 Go to previous message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
Quote:


‘K_CTRL_ALT_E’ was not declared in this scope



try
K_CTRL | K_ALT | K_E

instead.
K_CTRL, K_ALT, K_SHIFT each occupies a unique bit, and can be bit-or'ed together with other keys.
Previous Topic: Moving to Linux dev from Win
Next Topic: Linux external libs
Goto Forum:
  


Current Time: Fri Apr 19 11:08:03 CEST 2024

Total time taken to generate the page: 0.02772 seconds