bugGNU Octave - Bugs: bug #44676, ginput() does not return mouse...

 
 

bug #44676: ginput() does not return mouse button value with Qt

Submitter:  Philip Nienhuis <philipnienhuis>
Submitted:  Tue 31 Mar 2015 11:34:01 AM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
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

Tue 31 Mar 2015 08:25:24 PM UTC, comment #9: 

Thanks, that was a very quick fix!

(Indeed Rik, I think 1,5 weeks ago it still worked, as scripts I made around that time that invoked ginput worked fine. Today I continued work on that code and ginput no longer worked)

Philip Nienhuis <philipnienhuis>
Group Member
Tue 31 Mar 2015 06:32:58 PM UTC, comment #8: 

I fixed Qt to behave the same as FLTK and include the button number when executing the windowbuttondownfcn callback (http://hg.savannah.gnu.org/hgweb/octave/rev/0376c1225660).

Rik <rik5>
Group administrator
Tue 31 Mar 2015 05:49:08 PM UTC, comment #7: 

I think we have a small Matlab incompatibility here.  Matlab's WindowButtonDownFcn is just a callback without arguments.  In Octave, the file ginput.m expects that the first argument to the callback is the button number.


function ginput_windowbuttondownfcn (src, button)
  point = get (gca (), "currentpoint");
  ginput_accumulator (1, point(1,1), point(1,2), button);
endfunction


And in _init_fltk_.cc  


if (fp.get_windowbuttondownfcn ().is_defined ())
     fp.execute_windowbuttondownfcn (Fl::event_button ());


so it works for FLTK.

In Canvas.cc, however,


          gh_manager::post_callback (figObj.get_handle (),
                                     "windowbuttondownfcn");

          gh_manager::post_callback (currentObj.get_handle (),
                                     "buttondownfcn", button_number (event));


so it doesn't work for Qt.

Easiest solution would be to add "button_number (event)" to the windowbuttondownfcn callback.

Alternatively, we can do what Matlab user's would do and check the "SelectionType" property of current figure to determine if it was "normal", "extended", or "alt".



Rik <rik5>
Group administrator
Tue 31 Mar 2015 05:29:15 PM UTC, comment #6: 

Yeah, I thought I fixed this problem recently with this patch:

  http://hg.savannah.gnu.org/hgweb/octave/rev/b38b677c0fa8

What happened?  Oh, I think it was this change:

  http://hg.savannah.gnu.org/hgweb/octave/rev/6e5365ee200a

Should be easy to fix by also passing the button number to the windowbuttondownfcn callback.

John W. Eaton <jwe>
Group administrator
Tue 31 Mar 2015 05:26:13 PM UTC, comment #5: 

I tried to use 'hg bisect', but I couldn't find when ginput was ever correctly reporting button clicks.  So, it  is confirmed that there is a problem with ginput and Qt.

Rik <rik5>
Group administrator
Tue 31 Mar 2015 03:38:42 PM UTC, comment #4: 

For gnuplot, it had been reported before on being a value of 1023 sometimes, which I had seen in Windows only and had been fixed by checking if was 1023 and setting the return value to 1 [1]



[1] https://savannah.gnu.org/bugs/?func=detailitem&item_id=42489


John Donoghue <lostbard>
Group Member
Tue 31 Mar 2015 03:35:57 PM UTC, comment #3: 

I'm pretty sure this is a recent regression.  I believe as recently as a few weeks ago this was working.  I'm adding jwe to the CC list since he was working on this code earlier.

Rik <rik5>
Group administrator
Tue 31 Mar 2015 03:22:12 PM UTC, comment #2: 

It looks like there may be a need for qt initialization like
at line 76 of ginput.m for fltk:
      if (strcmp (toolkit, "fltk"))
        _fltk_check_ ();
      endif
for qt ? But, it almost works for gnuplot:

>> [x,y,button]=ginput(3)

x =

   0.46300
   0.37694
   0.37694

y =

   0.77482
   0.67101
   0.66835

button =

      3
   1063
      2

>>

good, except button 1 shows as 1063

This is current devel on Fedora 21.

Michael Godfrey <godfrey>
Group Member
Tue 31 Mar 2015 02:51:29 PM UTC, comment #1: 

Doesn't work for the qt toolkit - fltk and gnuplot work.

Also does the same on my fedora box for the empty button array.

John Donoghue <lostbard>
Group Member
Tue 31 Mar 2015 11:34:01 AM UTC, original submission:  

[~, ~, b] = ginput () returns an empty value [](0x0) for b when a mouse button is clicked.
Expected is 1, 2, or 3, depending on which mouse button was pressed.

ginput() does return the ASCII value of pressed keyboard keys.

Philip Nienhuis <philipnienhuis>
Group Member

 

(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 jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by lostbard (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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-03-31 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-03-31 rik5 Summaryginput() does not return mouse button value ginput() does not return mouse button value with Qt
    2015-03-31 jwe Item GroupIncorrect Result Regression
        Summaryginput() does not return mouse button value with Qt ginput() does not return mouse button value
    2015-03-31 rik5 Item GroupRegression Incorrect Result
        Summaryginput() does not return mouse button value ginput() does not return mouse button value with Qt
    2015-03-31 rik5 Carbon-Copy- Added jwe
    2015-03-31 lostbard StatusNone Confirmed
        Operating SystemMicrosoft Windows Any

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code