Handle Graphics - run a callback function when mouse motion ceases??

Hi,
I'm building an interactive graphical app. I wish to run a callback function once the user stops moving the mouse over the graph, to bring up a pseudo tool-tip on the nearest entity. I don't wish to use any mouse button presses, as these are for other interactions.
I can't think of a simple way of triggering the callback, short of using the mouse motion to continually reset a timer object, which is pretty clunky.
Any ideas??

 採用された回答

Matt Fig
Matt Fig 2011 年 3 月 25 日

0 投票

I would perhaps not have the mouse motion reset a timer, but have the function which brings up the pseudo-tool-tip on a timer - say every .25 seconds. Then have the buttonmotionfcn set the the tool-tip to invisible.
Perhaps a little less clunky...

1 件のコメント

P_Farr
P_Farr 2011 年 3 月 28 日
Hi, thanks for your thoughts. I think my solution actually uses less cpus, as the timer is set for a singleshot countdown of maybe 0.5 second. At the first 'motion' the timer is stopped and restarted, and this repeats whilst there is motion. At the end of the motion, the final resetting concludes, the timer then runs it's callback, and repositions the 'pseudo tooltip'. My main issue is that it should be do-able without a timer having to exist at all....

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 3 月 25 日

0 投票

You could have the timer running all the time that the option is in effect, with timer repeat mode, configured so that the effect that the timer has is dependent on a flag that the motion callback clears when there is mouse motion.

2 件のコメント

P_Farr
P_Farr 2011 年 3 月 28 日
Hi, thanks for your input also. I really don't want timers running all the time if they can be avoided, but it seems the best option at the moment...
Walter Roberson
Walter Roberson 2011 年 3 月 28 日
Well, there is no specific callback for mouse motion stopping -- not unless there is one at the Java level.
Can you think of any time-outs in MATLAB that might be a model for the behaviour you would like to see? The only time-outs that I can think of at the moment are the time-outs waiting to see a terminator for serial I/O.

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

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

製品

質問済み:

2011 年 3 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by