Highlight Text

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 11 November 2004   #1
Question Highlight Text

is ther a way to highlight a text in an edittext box using a script?


rollout looper "Looper"
(
group ""
 (
 edittext syntax "" fieldWidth:270 offset:[0,-5]
 )
 
 on syntax entered input do with undo on
 (
  try
  (
   if syntax.text != undefined do
   (
   com1 = "for i in 1 to $.count do ($[i]."
   com2 = ")"
   com3 = com1 + syntax.text as string + com2
   execute com3
   print com3
   )
  )
  catch
  (
  --messageBox "Invalid Syntax"
  syntax.text = "Invalid Syntax"
  )
 )
)
createdialog looper 300 50 35 810


Im just trying to make a simple script for quick loops on selected objects. But what I hopefully intend to happen is that if ever an error occurs, the Text inside the edittext box would change then it it Highlighted... so that i cud just type a new syntax without grabbing the mouse to highlight and delete the message.
 
Old 11 November 2004   #2
Originally Posted by galagast: is ther a way to highlight a text in an edittext box using a script?
Don't think it is possible (it is a Windows thing after all).
How about outputting the error message into a label or something?

Btw, I also fixed the loop because it would fail if only one object was selected. ($ does not returns a collection when a single object is selected, it returns the object itself).

Also, the .text property of the edittext can never be undefined. It can be empty string though...

rollout looper "Looper"
 (
  group ""
  (
   edittext syntax "" fieldWidth:270 offset:[0,-5]
   label messages "Ready."
  )
  
  on syntax changed txt do
  (
 	 messages.text = "Typing...Press Enter to evaluate."
  )
  on syntax entered input do with undo on
  (
   try
   (
    if syntax.text != "" do
    (
    com1 = "for i in selection do (i."
    com2 = ")"
    com3 = com1 + syntax.text as string + com2
    execute com3
    print com3
    messages.text = "Ready."
    )
   )
   catch
   (
   messages.text = "Invalid Syntax"
   )
  )
 )
 createdialog looper 300 60 35 810

Last edited by Bobo : 11 November 2004 at 04:20 PM.
 
Old 11 November 2004   #3
thanks bobo!! ive learned a lot from your wedsite tutorials and scripts!
yeah, it was a windows thingy after all..
though i doesnt seem to work if i press enter consecutively, so i decided to finally add buttons.. which i initially wanted to refrain from doing.
Oh, I was always used to using "i in $.count" , I didnt realize that "i in selection" was better, hehe, my work around was adding to "if then"s, just to check if the selection was 1, or many. Thank you for pointing it out for me! more energy for you master bobo!

here's the new code

rollout looper "Looper"
 (
  group ""
  (
   edittext syntax "" fieldWidth:270 offset:[0,-5]
   button apply "Ready" width:220 offset:[45,-4] across:2
   button clear "Clear" width:50 offset:[45,-4]
  )
  
  on syntax changed txt do
  (
   apply.text = "Typing...Press to evaluate."
  )
  on apply pressed do with undo on
  (
   try
   (
	if syntax.text != "" do
	(
	com1 = "for i in selection do (i."
	com2 = ")"
	com3 = com1 + syntax.text as string + com2
	execute com3
	print com3
	apply.text = "Click when Ready."
	)
   )
   catch
   (
   apply.text = "Invalid Syntax"
   )
  )
  on clear pressed do with undo on
  (
  syntax.text = ""
  apply.text = "Ready"
  )
 )
 createdialog looper 300 60 35 810 
 
Old 01 January 2006   #4
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



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 05:09 AM.


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