How I set a string in edit field when string is longer than the field itself

4 Ansichten (letzte 30 Tage)
Hi guys,
I have an idea how I want it to behave but I have no clue how to do it. So I beg for help :)
I have edit field with for exaple max. 15 char...and I have char with for example 26 char and when i put it there I want to bw shown in edit field the end of the string and to sign that some of the text is missing I want there to be '...'
In example it will be better:
edit field 15char: xxxxxxxxxxxxxxx
string 26 char: abcdefgh...xyz
and when I put the sting in the field I want it to be shown like: ...opqrstuvwxyz
Thanks for replies...Peter
  4 Kommentare
Walter Roberson
Walter Roberson am 5 Nov. 2012
You can set the KeyPressFunction callback in a uicontrol() of style 'edit' and so it is possible to do as the user types.
Petr
Petr am 5 Nov. 2012
I dont need it to be interactive...showing after setting the field string is OK...
To be specific...I am setting in the edit field a path to chosen file by uigetfile...

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

per isakson
per isakson am 5 Nov. 2012
I assume you refer to an uicontrol of style: edit, text or listbox.
Idea: store the full string in UserData and truncate before you set the property, String, of the uicontrol.
  2 Kommentare
Petr
Petr am 6 Nov. 2012
Bearbeitet: Petr am 6 Nov. 2012
Thanks, I also thought about it like that...but...isnt there a much more elegant way ?
Walter Roberson
Walter Roberson am 6 Nov. 2012
No there isn't. It might be possible using Java controls, but getting access to those controls is not elegant.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 5 Nov. 2012
There is no setting you can make at the MATLAB level to cause the uicontrol displayed string to have the ellipses and yet for the control's String property to have the full contents. I do not know if it could be done at the Java level.
You can set() the String property to display any given string, including a literal '...' but that contents will be what is retrieved when you get() the String property.

Kategorien

Mehr zu App Building finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by