CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 07-03-2013, 10:07 AM   #1
DeadlyNightshade
Plz...
 
DeadlyNightshade's Avatar
portfolio
Martin Dahlin
Jr. Technical Artist
King
Stockholm, Sweden
 
Join Date: Jul 2012
Posts: 922
Deleting last entry in a textField via a command

I'm wondering if there is any way to delete the last entry in a textField via a command?
Sure there's always backspace, but let us assume that this field cannot be modified via the keyboard but only via commands.

You have the
-insertText -flag for inserting new stuff into the field but no flag for deleting things.

NOTE: I'm not interested in textField -e -text "" $field;
I want to delete the last entry.

Tokenizing the field text, store in an array and delete last array entry seems like a sloppy solution, so maybe another approach would be to create some kind of undo-queue for the field by using optionVars?

What are your thoughts?
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.
 
Old 07-03-2013, 10:42 AM   #2
djx
Where's my pony?
 
djx's Avatar
David Johnson
vfx & creature td
Melbourne, Australia
 
Join Date: Jun 2003
Posts: 3,464
I dont quite understand why you think tokenize would be sloppy. Write a little proc that takes a string and returns the same string with the required number of fields omitted. Once you have that, your actual code would only be 3 lines. 1 to query the current text, 1 to call your truncate proc and 1 to edit the textfield.

The bonus is your truncate proc can be written to be a little more general that omitting just the last field. Pass in a flag that tells it how many fields to remove, from which end, with what delimiter, etc. Then you have something you can re-use in all your other scripts that deal with text strings.

If you did this in python it would be even easier, and you could do it in a single line.

David
__________________
http://www.djx.com.au
 
Old 07-03-2013, 05:25 PM   #3
DeadlyNightshade
Plz...
 
DeadlyNightshade's Avatar
portfolio
Martin Dahlin
Jr. Technical Artist
King
Stockholm, Sweden
 
Join Date: Jul 2012
Posts: 922
Tokenize requires a separation character (: or _ most commonly used by ppl) and that wouldn't be of any help to be as the string I have can be highly random.

Either way, I found the page in the manual for the substring command and I think I'll just do a small procedure using that command (calc size of string, minus one, save substring to the string var).
__________________
Nightshade UV Editor (script for Maya) - Extends Maya's default UV Texture Editor with additional tools.
 
Old 07-03-2013, 05:25 PM   #4
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:20 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.