If mouse click in this rectangle, display rectangle in green

8 ビュー (過去 30 日間)
Iris Müller Iris Müller
Iris Müller Iris Müller 2013 年 2 月 25 日
Hi!
I´m writing a psychological experiment (at least I try to), in which students shall click on a rectangle in my figure (on the screen). If they clicked on the correct rectangle the rectangle shall become green and it should be counted as a hit.
This was my code (which did not work):
if ('WindowButtonDownFcn', rectangle('Position', [0.7,0.4,0.1,0.1], 'facecolor', 'w'))
disp(rectangle('Position', [0.7,0.4,0.1,0.1], 'facecolor', 'g'))
Thanks for help!!
  1 件のコメント
Jan
Jan 2013 年 3 月 7 日
This code is very weird.

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

回答 (3 件)

Doug Hull
Doug Hull 2013 年 2 月 25 日
You need to set callbacks on the rectangle.
This shows setting callbacks, the lessons should be similar.

Iris Müller Iris Müller
Iris Müller Iris Müller 2013 年 3 月 5 日
Oh cool! it works!! Thankk you! :)

Iris Müller Iris Müller
Iris Müller Iris Müller 2013 年 3 月 7 日
I have one more question: Now, regardless of where the subjects click, the rectangle becomes green (and the other rectangles become red). What I want is: 1 mouse click per trial. if they click on the correct rectangle only this shall become green to tell the subjects they made a hit. And the other rectangles shall remain white. If they click on another rectangle it shall become red. Moreover, I would like Matlab to report on which rectangles they clicked (something like 1=hit, 0=wrong rectanlge).
Thank you again!!
  1 件のコメント
Jan
Jan 2013 年 3 月 7 日
The conventions in this forum are to accept an asnwer, if it has solved the problem. For a new question, a new thread is created. Posting the working solution is appreciated.

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

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by