필터 지우기
필터 지우기

How to create an uicontrol with selectable but non-editable text.

조회 수: 7 (최근 30일)
bbb_bbb
bbb_bbb 2018년 4월 25일
댓글: Ameer Hamza 2018년 4월 25일
I want to allow user copy a text (or it's part) into clipboard in usual manner (selecting by mouse and pressing Ctrl-C). How to make it? A 'text' style uicontrol doesn't permit selection. Оn the other hand, an 'edit' style permits selection and copying to clipbord but also allows editing what is not desirable.

답변 (2개)

bbb_bbb
bbb_bbb 2018년 4월 25일
편집: bbb_bbb 2018년 4월 25일
found "simple" solution:
javatxt = findjobj(editui);
javatxt.Editable=0;
where editui - an 'edit' style uicontrol,
findjobj - a function that Find java objects contained within a specified java container or Matlab GUI handle
  댓글 수: 1
Ameer Hamza
Ameer Hamza 2018년 4월 25일
Worth mentioning that findjobj is not a MATLAB built-in function. It is available FEX::findjobj here.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2018년 4월 25일
Hack the Java objects underlying the uicontrol.
But first experiment with setting the uicontrol enable property to 'disable'. The result is a uicontrol that can still scroll but not be edited. I do not recall whether it is selectable.
  댓글 수: 2
bbb_bbb
bbb_bbb 2018년 4월 25일
set(textui, 'Enable', 'off') - gives non-selectable text.
Dennis
Dennis 2018년 4월 25일

If it is okay to copy the entire text you could create a ButtonDownFcn that copies the string to clipboard.

function copytxt (hobj,~)
      mystring=get(hObj,'String'); 
      clipboard('copy',mystring)
end

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by