이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Any help on this topic would be appreciated. I need this in the next 18 hours!
I am trying to create a GUI which has an edittext box and when you click on it, a keyboard made of pushbuttons pops up.
I want to know how to get this keyboard to work. One problem I am having is that it does not pop up immediately when I click the edittext, I have to press enter to make it come.
I'd like the keyboard to update the edittext box on the original GUI as I press the buttons!
채택된 답변
Sean de Wolski
2013년 4월 22일
I just answered something similar last week:
As for getting the editbox to poof the new window, you might have to use a regular textbox's 'ButtonDownFcn'. This is because an editbox will allow you to edit with the keyboard on click where a textbox gives you the ability program what happens when you click on it.
댓글 수: 7
This came up on my Google search but it made little sense to me. I am not very experienced with MATLAB, I have experience with C and Java.
Will all that code be in the calling GUI, or in the keyboard GUI? Also, how can I make this work with my existing pushbuttons keyboard?
Edit: I would like the code to work from the keyboard GUI because I have multiple editboxes and multiple GUIs which all access the same keyboard.
This is all in one GUI, it will be your job to break it into two. The thought process is the same though. To run it, simply save the file to the name of the function and run that name at the command line:
>>OnScreenKeyboard
Could you explain the function AddLetter to me?
function AddLetter(letter)
%Called when letter pressed
%Add letter to string
set(hEdit,'string',strcat(get(hEdit,'string'),letter));
drawnow;
%NOTE: Obviously, you'll need to add features here such as
%backspace etc.
end
It takes in the letter to add. Then it adds it to the end of the current string and sets the current string to be the new one. The drawnow is just to make sure this happens. Since it's a nested function, it has access to any variables in the parent function, this is how it knows about hEdit
OK I figured it out. Thanks a lot! It works perfect.
One last problem. How can I return the entire string from the keyboard .m file to the GUI to display in the edittext box?
I started by adding this to the keyboard function- function str = OnScreenKeyboard
and in the GUI, I have str = OnScreenKeyboard; set(edit2,'String',str); where edit2 is the edittext box.
Should I code an Enter button which would tell the GUI that I am done typing now and now you should update edittext?
That would be one way. Another would be to define str first. And then set it to the string of the edit box after. This will create str in the workspace:
str = strcat(etc,letter)
set(hEdit,'str',str)
You will still likely need a uiwait on the figure to wait until either a button is pressed to indicate that the user is done typing or the figure is closed.
One last problem. AddLetter has the complete string. How do I pass it from AddLetter to OnScreenKeyboard? I used a global in OSK and changed it in AL to keep track of the main string, but I can't find a way to set OSC's output variable equal to this global.
% code
function [str] = OnScreenKeyboard
global str2;
str2 = '';
and then inside AddLetter
% code
str2 = strcat(str2,letter);
and then right outside AddLetter
% code
str = str2;
but the problem is the control of the program never reaches that last statement, so str is always ''
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Desktop에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
