Filter löschen
Filter löschen

CurrentPoint in UIFigure as a ginput workaround for App Designer

16 Ansichten (letzte 30 Tage)
Matt_Z
Matt_Z am 12 Dez. 2018
Bearbeitet: Carl Lindquist am 18 Apr. 2019
I trying to create a workaround to the lack of ginput functionality in the new App Designer UIFigure. The idea is to do the following:
  1. Use the CurrentPoint callback to register the pixel location
  2. Use pixel bounding box of axes InnerPosition and inpolygon to first confirm that click was within axes
  3. Convert CurrentPoint position to axes position based on scaling coordinates within axes and Xlim/Ylim properties
The issue I run into is the axes itself in the UIfigure appears to corrupt the CurrentPoint parameter. Using the image below to highlight the issue, for the UIFigure (with Position property = [312 336 1284 653]) I get the following 'CurrentPoint' results for the four locations shown:
  1. [191 140]
  2. [319 210]
  3. [1342 210]
  4. [911 152]
So it seems that Points 1 and 4, outside the UIAxes, are fine (i.e. line up well with the UIFigure Position property) but 2 and 3 are seemingly 'corrupted' (or rescaled).
Has anyone experienced this or knows that I might have wrong?
I am using Matlab 2018b
  1 Kommentar
Carl Lindquist
Carl Lindquist am 18 Apr. 2019
Bearbeitet: Carl Lindquist am 18 Apr. 2019
Sorry for being late to the party, ju might already have solved this...? In that case, how did you do it? If not, here as a suggestion!
Answer
I have a similar experience! I encountered this in a complied Web App, where it seems as if CurrentPoint returns the mouse position relative to the browser window only when inside the UIAxes, but relative the the lower left corner of the UIFigure elsewhere. I digged around in the undocumented properties for a while, but wasn't able to locate the size of the actual browser window. I'm sure it's in there somewhere though...
Do you experience this in an uncomplied app...? In that case, the following works for me. I set the WindowButtonMotionFcn callback and then poll the event.Source.CurrentPoint inside the callback to get the location of the pointer.
To just record the mouse click inside a UIAxes, one can do
ax = struct(app.UIAxes).Axes;
ax.ButtonDownFcn = @(h, e) click_selection(app);
...where click_selection is some callback function that one can define. Using struct() on an object might cause MATLAB to complain a bit, so if the warning annoys you, you can set
warning off MATLAB:structOnObject
to shut it up.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Develop uifigure-Based Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by