|
From: | Julien Bect |
Subject: | Re: Matlab compatibility for keypressfcn |
Date: | Sun, 19 Apr 2015 09:43:15 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
Le 19/04/2015 00:30, Rik a écrit :
4/18/15 Does anyone know if the callback for keypressfcn is executed when a modifier key is pressed alone? I'm debugging problems with ginput() and have found that Octave will execute the callback for any actual key pressed including the modifiers like SHIFT and CTRL. This is rather awkward because generally the modifiers are part of a key sequence like <CTRL+C> and the there is no key in the data structure for the first part of the sequence when CTRL is pressed by itself. Sample code, if necessary, for testing In file mycb.m: function mycb () disp ('mycb called'); end Then, figure set (gcf, 'keypressfcn', @mycb) %% Now try typing just SHIFT or just CTRL in figure window and see if 'mycb called' is displayed.
# Result on Matalb R2012a / Ubuntu 14.10 32 bits # The callback gets called, but this results in an error: Error using mycb Too many input arguments. Error while evaluating figure KeyPressFcn # If I modify the callback as follows: function mycb (varargin) disp ('mycb called'); varargin{:} end # I get the result: mycb called ans = 1 ans = Character: '' Modifier: {'control'} Key: 'control'# So, the answer is yes: the callback is executed when a modifier key is pressed alone
[Prev in Thread] | Current Thread | [Next in Thread] |