GUI / GUIDE - Ask to select a line

7 ビュー (過去 30 日間)
Luca Amerio
Luca Amerio 2015 年 5 月 26 日
回答済み: Jan 2015 年 5 月 26 日
Is it possible to ask user to select a line during the execution of a GUI?
I would like a popup to appear asking "please select a line", waiting the user to do so and then return the handle to the code.
I could only think of using ginput, but then I would need to cycle through all the children of that figure to find the closest line to the selected point. Any smarter way?
  1 件のコメント
Ingrid
Ingrid 2015 年 5 月 26 日
I wouldn't use the children of the figure but just the data that you used to plot directly and than find to which data the closest point belongs which can be done in a vectorized way

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2015 年 5 月 26 日
The lines have a 'ButtonDownFcn', which can be used to detect a selection.
function test
line([0,10], [1,2], 'ButtonDownFcn', @LineCallback);
function LineCallback(LineH, EventData)
set(LineH, 'LineWidth', 3);
This can be expanded, e.g. by storing all line handles in the figures ApplicationData (see guidata) and deselecting all other lines when a new line is selected.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by