views:

2754

answers:

6

I know about the buttonMode property on a MovieClip (to get the hand cursor on hover) and I'm looking to do the same with a TextField, but it doesn't seem to implement this property. Does anyone know if there's anything similar or, failing that, another way to control the cursor for the textfield?

Thanks for any ideas :)

+2  A: 

You can not set the hand cursor with the TextField the same way you can with a MovieClip. This makes sense if you think about it, a hand cursor on a Textfield is not user-friendly, users expect to input text into a TextField, not click it like a Button. However there is a work around that you can use.

Give the TextField an event listener for the mouse over event, then in the event handler set the cursor through CursorManager.

Should look something like ...

myTextField.addEventLstener(MouseEvent.MOUSE_OVER, onMouseOver);

private function onMouseOver( event : MouseEvent ) : void{
   CursorManager.setCursor(cursorClass, priority, xOffset, yOffset);
}
ForYourOwnGood
+2  A: 

Alternatively you could put the textfield inside a movieclip and set the buttonmode to true on that. That's basically how the bulit in button components work and is an acceptable solution for this particular problem.

James Hay
A: 

Thanks guys for your answers ...

@James: I'm extending the MovieClip class and then creating objects from inside the cllass (including the textfield) in code, which complicates things a bit (if only in my fragile brain). The weird thing is that I've set buttonMode = true on the MC, and it applies to everything except the TextField, when it reverts to the caret (or just the pointer if I set Selectable = false on the TextField).

@ForYourOwnGood: Point taken about usability, but I want the textfield to be a seamless part of a bigger object, and it just doesn't feel right without the hand cursor. What you supplied sounds like just what I need, but it looks like it's Flex specific? I can't find the equivalent in Flash (specifically CS4), despite trawling through LiveDocs. Am I being dim? :S

Thanks again for your help, both of you :)

Dan
Your comments are not answers and should therefore be left as ... comments.
Joe Philllips
+3  A: 

try adding

mouseChildren = false; (in the class that extends MovieClip)

It should stop the textfield from being mouse enabled.

James Hay
A: 

Absolutely spot on ... you're a genius :)

Thanks a lot for your time and saving me mine. It's the little things like this that can really waste a lot of it!

Dan
A: 

I would very primitively place a alpha=0 movieClip on top of the textfield / label of your button, that also brings the handCursor back