フィルターのクリア

How to programmatically scroll down multiline edit box ?

9 ビュー (過去 30 日間)
p fontaine
p fontaine 2011 年 2 月 21 日
回答済み: 谢文 刘 2022 年 5 月 13 日
When writing in a multiline edit box I would like to get it scrolled down automatically. How can I do ?
  1 件のコメント
Jiro Doke
Jiro Doke 2011 年 2 月 21 日
A multiline edit box WILL scroll down automatically if you keep entering text beyond the visible rows. It will scroll in order to show the current cursor location.
Are you asking how to scroll to a specific location? Then I think Walter's answer covers it.

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

採用された回答

Walter Roberson
Walter Roberson 2011 年 2 月 21 日
I seem to recall that Yair Altman has a way to do it by going in at the Java level. See his UndocumentedMatlab site .
There is no supported method of doing it.
Well, not that would be acceptable to most people. If you put the edit box inside of a uipanel and set the panel to clipping, you can set the Position of the edit box within the uipanel in order to scroll / pan the edit box. Getting this to work in concert with the scroll bars of the edit box is whole other problem...

その他の回答 (2 件)

Yair Altman
Yair Altman 2011 年 4 月 11 日

谢文 刘
谢文 刘 2022 年 5 月 13 日
If your original idea is to display the newest data you got on edit panel and not to delete the previous data, I think I have a solution with Yair Altman's methods.
Here is my code.
function SetToBottom(hObject,~)
set(hObject,'VerticalScrollBarPolicy',javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
hObject.getVerticalScrollBar.setValue(hObject.getVerticalScrollBar.getMaximum);
hObject.repaint;
%When edit box is created, function 'SetToBottom' is added into
%'AdjustmentValueChangedCallback' which is called when 'String' is changed
function receivetext_CreateFcn(hObject, ~, ~)
% hObject handle to receivetext (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
jhEdit = findjobj(hObject);
hjScrollPane = handle(jhEdit,'CallbackProperties');
set(hjScrollPane,'AdjustmentValueChangedCallback',@SetToBottom);
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
Forgive my grammatical mistakes.

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by