Mouse clicking call back

2 ビュー (過去 30 日間)
Abolfazl Nejatian
Abolfazl Nejatian 2016 年 12 月 14 日
編集済み: Abolfazl Nejatian 2016 年 12 月 15 日
I’ve a dynamic text in Matlab GUI that I need to convert it’s string to blank or (‘’) by Left mouse clicking on it. Any help would be appreciated Many tanks Nejatian

採用された回答

Antonio Aguirre
Antonio Aguirre 2016 年 12 月 14 日
編集済み: Antonio Aguirre 2016 年 12 月 14 日
% --- If Enable == 'on', executes on mouse press in 5 pixel border. % --- Otherwise, executes on mouse press in 5 pixel border or over text2.
________________________________
function text2_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to text2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(hObject,'String','')
____________________________
Add the code above to your .m file containing the code for your GUI. Where it declares the function name (i.e. text2_ButtonDownFcn) you would replace the text2 with the 'tag' name associated with your particular text field. You can find the 'tag' of any GUI object by opening your GUI through guide and simply clicking on a particular feature of the GUI and looking in the bottom left hand corner of the window.
In this function you can implement changes to any of the associated properties of the particular object that has been clicked on, perform calculations, etc.
Let me know if you have any questions. Also, almost forgot, you should add the following line of code to your createFcn for what ever text field or text box you are applying this to set(hObject,'Enable','inactive');
  1 件のコメント
Abolfazl Nejatian
Abolfazl Nejatian 2016 年 12 月 15 日
編集済み: Abolfazl Nejatian 2016 年 12 月 15 日
thanks Antonio to your answer.your answer was helpful for me but i couldn't understand why you mentioned set its hObject to 'inactive'?

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

その他の回答 (0 件)

カテゴリ

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