bugGNU Octave - Bugs: bug #60829, "keypressfcn" property...

 
 

bug #60829: "keypressfcn" property not implemented for uicontrol objects

Submitted by:  None
Submitted on:  Sat 26 Jun 2021 09:54:46 PM UTC  
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Postponed Assigned to:  None
Originator Name:  Paul Mennen Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  dev
Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 28 Jun 2021 09:51:54 PM UTC, comment #1: 

I did some digging and I believe the root cause is simply that the "keypressfcn" property is not implemented for uicontrol objects, whereas it is for figure objects. 

Rik <rik5>
Project Administrator
Sat 26 Jun 2021 09:54:46 PM UTC, original submission:  

I'm converting a GUI application from Matlab that depends on being able to edit the text on various uicontrol objects. Below is a short routine the demonstrates this. This program creates a uicontrol text object with the string 'A'. When you left click on it, the string increments (i.e. to 'B', then to 'C', etc.). When you right click on it, the uicontrol string is then set to the next character you type on the keyboard. This works perfectly in all Matlab versions:

function keytest(in)
  if ~nargin  % create uicontrol object
    uicontrol('style','text','enable','inactive','string','A','buttondownfcn','keytest(1)',...
              'backgroundcolor','black','foregroundcolor','white');
  elseif in
    if strcmp(get(gcf,'SelectionType'),'alt')             % buttondownfcn --------
          set(gcf,'keypressfcn','keytest(0)');            % right click comes here
          set(gcbo,'keypressfcn','keytest(0)');           % just in case (not needed in Matlab)
          set(gcbo,'string','___');                       % indicate waiting for keypress
    else  set(gcbo,'string',char(get(gcbo,'string')+1));  % left click comes here
    end;
  else set(findobj(gcf,'style','text'),'string',get(gcf,'currentcharacter')); % keypressfcn
  end;

When I run this in Octave, left clicking works as expected ... i.e. the character is incremented. When you right click, the string changes to underscores indicating that it is waiting for keyboard input however when you type a key, nothing happens! If after the right click you then left click on the figure anywhere other than the uicontrol, the keyboard input will be accepted and saved properly in the uicontrol string. However I think you would agree that this would be too clumsy to expect a user of the program to do this.

If anyone can think of a workaround for this problem, please let me know. I believe I could get it to work by reversing the  roles of the left and right clicks, however this would not be intuitive, since the left click operation is the far more frequent one. (Also a user of my Matlab program would be very confused.)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-06-28 rik5 CategoryNone => Plotting with OpenGL
        Item GroupIncorrect Result => Matlab Compatibility
        StatusNone => Postponed
        Release6.1.0 => dev
        Operating SystemMicrosoft Windows => Any
        Summarykeypressfcn does not get called after a right click => "keypressfcn" property not implemented for uicontrol objects

    Back to the top


    Powered by Savane 3.6