bugGNU Octave - Bugs: bug #44832, Qt: first call to ginput() doesn't...

 
 

bug #44832: Qt: first call to ginput() doesn't recognize keyboard key press

Submitter:  Philip Nienhuis <philipnienhuis>
Submitted:  Tue 14 Apr 2015 12:15:56 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Philip Nienhuis Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 22 Jun 2015 09:06:18 PM UTC, comment #13: 

Rik,

With JohnD's simple patch it works satisfactorily for me.

Reading back your comments, I realize it didn't even occur to me that ginput() could (should?) also raise the plot window.

I use the key press option of ginput() to return info about features under the cursor on a topographical map or cross-section drawn by Octave, so the plot will always have to be on top.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 22 Jun 2015 07:29:16 PM UTC, comment #12: 

For the key press, we would need to shift focus from the command window to the plot window, but only when ginput() is called.  Theoretically, shg() should do this, but today it only implements drawnow() which refreshes the window and does not bring it to the top of the stack nor set the focus on it.

Probably can be done, but it probably means adding a C++ function for shg() which will then delegate to the correct toolkit which will in turn call something like SetFocus().

Rik <rik5>
Group administrator
Mon 22 Jun 2015 07:05:56 PM UTC, comment #11: 

OK thanks, I'll have a look.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 22 Jun 2015 06:43:56 PM UTC, comment #10: 

Works to recognize without first click (although the plot window does need to be active)

John Donoghue <lostbard>
Group Member
Mon 22 Jun 2015 06:12:24 PM UTC, comment #9: 

Hmmm, I disagree with comment #7. The bug reported in comment #0 hasn't been fixed, has it.

Just compare the course of things with fltk. No need there to make a plot window active; ginput() simply connects to the current plot window handle. A similar thing needs to happen for Qt.

As to the patch, what am I missing here?
The first mouse click was already detected fine, no need to fix that.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 22 Jun 2015 05:24:54 PM UTC, comment #8: 

Pushed http://hg.savannah.gnu.org/hgweb/octave/rev/efe22f9b53a3

I guess a preferences setting for whether or now the bring the plot to the front could be used

John Donoghue <lostbard>
Group Member
Mon 22 Jun 2015 04:31:15 PM UTC, comment #7: 

The patch in comment #6 works to recognize the first mouse click. 

The code example in comment #0 which uses the keyboard still doesn't work.  Instead, I need to do something which makes the window active first, such as clicking on the plot window or using Alt+Tab to switch focus from the command window to the plot window, before ginput will work.

I think that is probably good enough because I know there were users who want the focus to remain with the command window for keyboard input so they can keep entering new commands rather than have the focus pulled over to the plot window.

Thus, I think this patch can be committed and the report closed.

Rik <rik5>
Group administrator
Mon 22 Jun 2015 04:09:17 PM UTC, comment #6: 

This allows keyboard press to work for me


(file #34292)

John Donoghue <lostbard>
Group Member
Thu 30 Apr 2015 09:23:11 PM UTC, comment #5: 

Maybe ask the question on the Octave mailing list?  Somebody who is following the Qt development closely should have an idea.

Rik <rik5>
Group administrator
Thu 30 Apr 2015 09:05:10 PM UTC, comment #4: 

How can the Canvas be made active when axes become active?

Philip Nienhuis <philipnienhuis>
Group Member
Tue 14 Apr 2015 07:46:09 PM UTC, comment #3: 

I just tested on Linux -> same issue -> OS set to Any

Philip Nienhuis <philipnienhuis>
Group Member
Tue 14 Apr 2015 07:32:23 PM UTC, comment #2: 

Confirmed.  Doubtless this is something really small.  The callback routine is Canvas::canvasKeyPressEvent in libgui/graphics/Canvas.cc.  Debugging with some print statements shows that the callback is never called from Qt until a mouse click has selected the Canvas.  Probably this means we need to make the Canvas an active object whenever a figure or axes becomes active.

Rik <rik5>
Group administrator
Tue 14 Apr 2015 12:32:53 PM UTC, comment #1: 

With gnuplot it all works fine.

Philip Nienhuis <philipnienhuis>
Group Member
Tue 14 Apr 2015 12:15:56 PM UTC, original submission:  

Steps to reproduce (with qt toolkit):

1. plot ([1 3])    # gives some simple plot

2. [a, b, c] = ginput (1)

3. # position mouse cursor over plot. Hmmm, cursor doesn't change into crosshair like Matlab does and like the fltk toolkit used  to do in 3.8.2
4. # press any letter key
# => nothing happens

Now, try again and click somewhere in the plot => ginput catches the mouse click. From now on key presses are recognized in next calls to ginput()

==> Key presses are only recognized after a first mouse click.

This works fine with the fltk toolkit.

Philip Nienhuis <philipnienhuis>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #34292:  bug44832.patch added by lostbard (654B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-22 rik5 SummaryQt: first call to ginput() doesn\'t recognize keyboard key press Qt: first call to ginput() doesn't recognize keyboard key press
    2015-06-22 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-06-22 lostbard Attached File- Added bug44832.patch, #34292
    2015-04-14 philipnienhuis Operating SystemMicrosoft Windows Any
    2015-04-14 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code