Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
About behavior of KeyPressFcn

Subject: About behavior of KeyPressFcn

From: Jeroen Boschma

Date: 8 Oct, 2007 11:00:37

Message: 1 of 5

Hi all,

I'm using KeyPressFcn for an edit control. The problem is that within
KeyPressFcn I need the actual String of the edit control _including_ the
last typed character. However, within KeyPressFcn I only can get the 'old'
value of the edit control before the key was pressed. This is of no use to
me... Does anybody know a workaround for this without writing a complete
interpreter for all keystrokes such that I have to calculate myself what the
new contents of the edit control will be?

Thanx,

   Jeroen

Subject: About behavior of KeyPressFcn

From: Yair Altman

Date: 8 Oct, 2007 11:37:42

Message: 2 of 5

"Jeroen Boschma" <no_mail@please.com> wrote in message
<470a0dd5$1@aurora.telecom.tno.nl>...
> Hi all,
>
> I'm using KeyPressFcn for an edit control. The problem is
that within
> KeyPressFcn I need the actual String of the edit control
_including_ the
> last typed character. However, within KeyPressFcn I only
can get the 'old'
> value of the edit control before the key was pressed. This
is of no use to
> me... Does anybody know a workaround for this without
writing a complete
> interpreter for all keystrokes such that I have to
calculate myself what the
> new contents of the edit control will be?
>
> Thanx,
>
> Jeroen


http://www.mathworks.com/matlabcentral/newsreader/view_thread/151905

Yair Altman
http://ymasoftware.com

Subject: About behavior of KeyPressFcn

From: Jeroen Boschma

Date: 8 Oct, 2007 12:12:49

Message: 3 of 5


"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
news:fed4q6$d89$1@fred.mathworks.com...
> "Jeroen Boschma" <no_mail@please.com> wrote in message
> <470a0dd5$1@aurora.telecom.tno.nl>...
>> Hi all,
>>
>> I'm using KeyPressFcn for an edit control. The problem is
> that within
>> KeyPressFcn I need the actual String of the edit control
> _including_ the
>> last typed character. However, within KeyPressFcn I only
> can get the 'old'
>> value of the edit control before the key was pressed. This
> is of no use to
>> me... Does anybody know a workaround for this without
> writing a complete
>> interpreter for all keystrokes such that I have to
> calculate myself what the
>> new contents of the edit control will be?
>>
>> Thanx,
>>
>> Jeroen
>
>
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/151905
>
> Yair Altman
> http://ymasoftware.com
>
>
OK, thanks for the pointer Yair. I downloaded your 'findjobj' and try to
find out the essence of it so I can write a smaller version of the whole
underlying idea, for performance issues. Only need the single 'edit'-thingie
:-)

   Jeroen

Subject: About behavior of KeyPressFcn

From: Jason Wang

Date: 7 Jul, 2010 20:16:08

Message: 4 of 5

Sorry for bumping such an old topic! I just spent all afternoon finding the solution to this problem. I used FindJObj, which sort of worked, but was a ridiculously convoluted process. Turns out, the solution was to just put a short "pause" before retrieving the string. For example

pause(.5)
pathname=get(handles.pathBox,'String');

I'm not sure if this is ridiculously trivial, but I thought it might be useful to point out anyways, since it doesn't seem like anyone else has. Matlab's documentation on the function callbacks are way too sparse IMO!

Subject: About behavior of KeyPressFcn

From: Mohammed El-Said

Date: 7 Aug, 2010 11:58:04

Message: 5 of 5

"Jason Wang" <sjwang40@gmail.com> wrote in message <i12na8$n0s$1@fred.mathworks.com>...
> Sorry for bumping such an old topic! I just spent all afternoon finding the solution to this problem. I used FindJObj, which sort of worked, but was a ridiculously convoluted process. Turns out, the solution was to just put a short "pause" before retrieving the string. For example
>
> pause(.5)
> pathname=get(handles.pathBox,'String');
>
> I'm not sure if this is ridiculously trivial, but I thought it might be useful to point out anyways, since it doesn't seem like anyone else has. Matlab's documentation on the function callbacks are way too sparse IMO!

Dear Jason Wang
Thanks for posting a solution
your solution is working like a charm

and please feel free to bump all old topics if you have good solutions for them :)

Mohammed El-Said
www.mohammed-elsaid.tk

Tags for this Thread

No tags are associated with this thread.

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.

Contact us