Drawing changing background in a TextField

I have a TextField that holds URLs, and I’d like to mimic the behavior of Safari in which the field fills with a blue background from left to right as the web page loads. I’m sure I can do this by overlying a canvas on the TextField and drawing the text and the background. But I’m curious if there’s a simpler way, a way in which one can draw directly into the TextField. There is no Paint event, so it’s probably not possible, but I thought I’d ask to see if there is a workaround, with Declares for example.

instead of a textfield, use a canvas that emulate the textfield and write the text on the canvas.

Yes, I said I could do that. I’m asking if there’s a manipulate the TextField (which I want to keep because the user can edit the URL, and I do not want to write a full-fledged faux textfield with a canvas).

i think i must be so tired… i missed that part.

Thanks anyway. FWIW, I’ve implemented the canvas – almost there. It took about 2 hours to get right.

so how did u make it so user can type in into the canvas?

I didn’t. I just overlay a canvas on top of the textfield and draw the text and progress color into it. When the web page is finished loading I hide it and the user sees the textfield.

that is a real cool idea…

Did you make the progress color half-transparent so the textfield is partially visible in the background?

Another way to do this might be to just use a canvas that displays the text, but when the user clicks on the canvas, it hides itself and displays a textfield with the URL in it that the user can edit. In other words, only show the textfield during editing – the rest of the time it’s your custom canvas. Sort of the best of both words. Done right, the user would never know what you’re doing.

[quote=38306:@Marc Zeedar]Did you make the progress color half-transparent so the textfield is partially visible in the background?

Another way to do this might be to just use a canvas that displays the text, but when the user clicks on the canvas, it hides itself and displays a textfield with the URL in it that the user can edit. In other words, only show the textfield during editing – the rest of the time it’s your custom canvas. Sort of the best of both words. Done right, the user would never know what you’re doing.[/quote]

It’s pretty much the same thing in reverse. I might try the half-transparent canvas. But I can say that drawing the text on the opaque canvas (which obscures the textfield) works well, and you get nice crisp black text on the colored progress color.

For some reason setting g.transparency in the Canvas paint (to as much as 1.0) event isn’t working – it stays opaque. Perhaps it’s because I’m running Snow Leopard (Cocoa, of course)?