Thread Subject: Menu Accelerators don't include number pad?

Subject: Menu Accelerators don't include number pad?

From: Andy

Date: 24 Aug, 2009 20:22:18

Message: 1 of 3

I set some menu accelerators to 1, 2, 3 and 4. When running the GUI, if I use the row of numbers at the top of the keyboard, this works fine. If I use the number pad, nothing happens. Obviously, this behavior is less than ideal. Does anybody know what's going on here?

Subject: Menu Accelerators don't include number pad?

From: Ryan

Date: 1 Sep, 2009 00:00:24

Message: 2 of 3

"Andy " <theorigamist@gmail.com> wrote in message <h6uspq$1cn$1@fred.mathworks.com>...
> I set some menu accelerators to 1, 2, 3 and 4. When running the GUI, if I use the row of numbers at the top of the keyboard, this works fine. If I use the number pad, nothing happens. Obviously, this behavior is less than ideal. Does anybody know what's going on here?

I assume in your figure1_KeyPressFcn you have some code that grabs what the current character is:

currChar = get(handles.figure1,'CurrentCharacter');

What you may also be interested in is the current key. This is different. MATLAB sees the top keys as '1','2','3', etc. and the numpad keys as 'numpad1','numpad2','numpad3', etc., even though the 'CurrentCharacter' is the same between them. Try something like this in your key handler function:

currKey = get(handles.figure1,'CurrentKey');
if strcmp(currKey,'numpad1') || strcmp(currKey,'1')
     Do menu stuff...
elseif...

Subject: Menu Accelerators don't include number pad?

From: Andy

Date: 1 Sep, 2009 13:08:04

Message: 3 of 3

"Ryan" <rgehmli@sandia.gov> wrote in message <h7ho6o$a1v$1@fred.mathworks.com>...
> "Andy " <theorigamist@gmail.com> wrote in message <h6uspq$1cn$1@fred.mathworks.com>...
> > I set some menu accelerators to 1, 2, 3 and 4. When running the GUI, if I use the row of numbers at the top of the keyboard, this works fine. If I use the number pad, nothing happens. Obviously, this behavior is less than ideal. Does anybody know what's going on here?
>
> I assume in your figure1_KeyPressFcn you have some code that grabs what the current character is:
>
> currChar = get(handles.figure1,'CurrentCharacter');
>
> What you may also be interested in is the current key. This is different. MATLAB sees the top keys as '1','2','3', etc. and the numpad keys as 'numpad1','numpad2','numpad3', etc., even though the 'CurrentCharacter' is the same between them. Try something like this in your key handler function:
>
> currKey = get(handles.figure1,'CurrentKey');
> if strcmp(currKey,'numpad1') || strcmp(currKey,'1')
> Do menu stuff...
> elseif...

Thanks, this worked perfectly.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
keypressfcn Ryan 31 Aug, 2009 20:04:19
number keys Ryan 31 Aug, 2009 20:04:19
key handler Ryan 31 Aug, 2009 20:04:19
number pad Andy 24 Aug, 2009 16:24:23
accelerator Andy 24 Aug, 2009 16:24:23
rssFeed for this Thread

Contact us at files@mathworks.com