PDA

View Full Version : Highlight Text


galagast
11-05-2004, 05:13 AM
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.

Bobo
11-05-2004, 04:16 PM
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

galagast
11-06-2004, 09:40 AM
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

CGTalk Moderation
01-19-2006, 08:00 PM
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.