I'm using the following command to acquire a character from the keyboard while the focus is on a particular figure.
get(gcf,''CurrentCharacter'')
However, once the character is read the buffer is not cleared and the same character is read even the next time if I use this command in a loop. Is there a way to clear the character from the keyboard buffer?
Thanks.
Regards,
Priyanshu
I don't think so. Well, not officially. As far as the interface is
concerned, the current character remains current until it is changed.
You are intended to use the keypress callback to detect key presses. If
you wanted to, you could have the callback stuff the character away
somewhere, and then when your loop is ready for it, it could see what
the variable currently stored and set the variable to '' afterwards.
You can set the current character after reading it, though I am still not clear on why you would need to do this.
set(gcf,'currentch',char(1))
"Matt Fig" <spam...@yahoo.com> wrote in message <hrvl4a$865$1...@fred.mathworks.com>...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
switch double(get(gcf,'currentch'))
case 28 % left arrow
% move left
case 29 % right arrow
% move right
case 30 % up arrow
% move up
case 31 % down arrow
% move down
otherwise
end
set(gcf,'currentch','3') % or whatever, as long as it will go to OTHERWISE.
drawnow % Flush the event queue.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
??? Error using ==> set
Bad property value found.
Object Name : figure
Property Name : 'CurrentCharacter'.
"Matt Fig" <spam...@yahoo.com> wrote in message <hrvqoa$4rp$1...@fred.mathworks.com>...
It said bad property value, not that it was unwritable. What were you
trying to set it to?
Walter Roberson <robe...@hushmail.com> wrote in message <a1MEn.93$7d5...@newsfe17.iad>...
Walter Roberson <robe...@hushmail.com> wrote in message <a1MEn.93$7d5...@newsfe17.iad>...