Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to set the focus a movieclip in MX

Status
Not open for further replies.

jefargrafx

Instructor
May 24, 2001
273
0
0
US
I have a moveclip that I'm using as a button

I set it tabindex and it will receive tab input and work fine, but I want to move the focus to the button when in appears on the screen. It's part of a error dialog box.

I don't want the user to have to tab throguh all the fields to highlight the button and tehn press enter,

here's the code I have so far let me know what yall think

thanks
onClipEvent (load) {
stop ();
this.focusEnabled = true;
this.tabEnabled = 1;
this.tabIndex = 100;
Selection.setFocus(this);
createTextField("button_text",1,-75,-10.0,150,20);
// button_text.text = "Here's some text";
button_text.html = true;
button_text.htmlText = &quot;<TEXTFORMAT LEADING=\&quot;2\&quot;><P ALIGN=\&quot;CENTER\&quot;><FONT FACE=\&quot;Gill Sans Condensed\&quot; SIZE=\&quot;14\&quot; COLOR=\&quot;#FFFFFF\&quot;>OK</FONT></P></TEXTFORMAT>&quot;;
button_text.textColor = 0xFFFFFF;
button_text.border = false;
button_text.autoSize = false;
emphasisFormat = new TextFormat();
emphasisFormat.bold = true;
// emphasisFormat.size = 16;
// emphasisFormat.font = &quot;Georgia&quot;;
button_text.setTextFormat(emphasisFormat);
}
onClipEvent (enterFrame) {
//button_text_width = getProperty(_level0.new_button_MC.button_text, _width);
this.onSetFocus = function(oldFocus) {
this.gotoAndStop (&quot;over&quot;);
}
this.onKillFocus = function(newFocus) {
this.gotoAndStop (&quot;up&quot;);
}
}

onClipEvent (mouseMove) {
if (this.hitTest(_root._xmouse, _root._ymouse, true) && !buttonDown) {
this.gotoAndStop(&quot;over&quot;);
} else if (!hitTest(_root._xmouse, _root._ymouse, true) && !buttonDown) {
this.gotoAndStop(&quot;up&quot;);
}
updateAfterEvent();
}
onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
buttonDown = true;
this.gotoAndStop(&quot;down&quot;);
}
}
onClipEvent (mouseUp) {
buttonDown = false;
if (!this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.gotoAndStop(&quot;up&quot;);
} else {
this.gotoAndStop(&quot;over&quot;);
}
}


remember this button doesn't display until an error occurs

thanks again jef
 
I to am working on something like this. I have an instance where I create many controls onto the screen each at their own position according to an incoming communication. That communication specifies which control is to have focus initially without having to change the tab indexes on all the controls.

My problem is that I can not set the selected control from within the control itself so the use of

Selection.setFocus(this);

doesn't work. Instead I'm trying to pass in the eval of

this[itemOn]

where itemOn is the instance name of the control in string format, and this refers to the main timeline. So I tried the following:

Selection.setFocus(this[itemOn]);

But this doesn't work because I never see a yellow box or the cursor caret inside the text box control that should be first. I know the this[itemOn] reference does evaulate to the control I'm wanting because I use the same thing to assign parent values into the control objects.

If anyone's got any ideas I'd appreciate it greatly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top