octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #60829] keypressfcn does not get called after


From: anonymous
Subject: [Octave-bug-tracker] [bug #60829] keypressfcn does not get called after a right click
Date: Sat, 26 Jun 2021 17:54:48 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?60829>

                 Summary: keypressfcn does not get called after a right click
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Sat 26 Jun 2021 09:54:46 PM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: Paul Mennen
        Originator Email: paul@mennen.org
             Open/Closed: Open
                 Release: 6.1.0
         Discussion Lock: Any
        Operating System: Microsoft Windows

    _______________________________________________________

Details:

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.)






    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60829>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]