How to compose a formula in a GUI
6 次查看(过去 30 天)
显示 更早的评论
Hello,
In my GUI a have a list box (lstVariables) with variable names and an edit box (txtEditor) where I want to write a formula. When I click in the list box, I want to add the selected variable in the edit box. The difficulty is that I want to add it on the place where the cursor was.
Example : I have in the edit box the text : "var1 + var2 + var3", I select in the edit box "var2" (so it's highlighted) and than I click in the listbox on var4. The result should be : "var1 + var4 + var3". How can I find which part of the edit box is selected ?
My Example code up to now :
function lstVariables_Callback(hObject, eventdata, handles)
varnames = cellstr(get(hObject,'String'))
varname = varnames{get(hObject,'Value')}
set(handles.txtEditor,'String',varname);
All help is appreciated.
Best regards,
Luc.
0 个评论
采纳的回答
Walter Roberson
2011-5-2
You will have to work at the Java level for this, in order to find out what was highlighted. I recommend that you look at Yair Altman's site, http://undocumentedmatlab.com
0 个评论
更多回答(1 个)
Luc
2011-5-2
1 个评论
Walter Roberson
2011-5-2
No text would have been selected at ButtonDownFcn time; the selection is made at ButtonUpFcn time.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!