Re: How to make TextBox read only but look normal

new topic     » goto parent     » topic index » view thread      » older message » newer message
DerekParnell said...
Dan_M said...
AndyDrummond said...

OK, this works. If you have a flag - I called it ROflag - which is True to make the control RO, and false to allow RW. You intercept the w32HEvent flag, and you test ROflag. If true do a returnValue(). This stops everything. But that includes painting. So you would need to leave ROflag false until the control is painted, setting it again afterwards to make the control inviolate.

You would probably be best to save the flag value in the main window onPaint handler, clearing it to allow the text to be painted, and restoring it after to the RO or RW state.

Does this make sense? It isn't terribly hygienic but it works. You can't do ANYTHING to the text box if the w32HEvent returnValue()'s.

Now we wait for Derek to tell us how it SHOULD be done...

Andy

. smile Does seem rather..Rube Goldberg!

Derek (and Greg) did earlier suggest to Tony to make the disabled edit more "presentable", by altering the background color of the disabled edit, which probably works just fine, I just thought that making the edit readonly and then altering that style as needed was a more elegant(?) approach, but then it didn't work, & I don't see why not.

Your way, though I guess it works, seems more like using an Elephant gun to shoot a mouse smile

Dan

I don't get it ... I already did say how it is to be done.

The user must have a visual clue that the field is not editable. You cannot just stop accepting events in the field because the user will not know that the program has changed state. You really have to show the user that the field is a no-go area. This GUI 101.

The simpliest way is to use setEnable(..., 0) and have the background colour change from the normal input scheme. That is why I suggest that during the program's form creation step, it should call setDisableBg() to set which colour to show when it's been disabled. That is all that has to be done! No fancy footwork or behind ther scenes redirecting of events.

There are many ways you can give visual hints that the field is disabled, but this is by far the easiest. I also suggested that one can change the colour of the text itself, but you could change the font/border/whatever..., but you have to do something.

Any field that looks like an input field should be editable. If it's not editable then it should not look like an input field.

Derek,

I did, above, mention that you and Greg had suggested a way to make edit box either editable or not, though I didn't go into any detail, since you already did. Maybe you thought you were responding to Andy's post, rather than my response to his post?

In any event, I continued to post regarding the matter because the method I thought to suggest, namely altering the STYLE of the edit box between read only and editable, with removeStyle( id, style ), DIDN'T ACTUALLY WORK, and I couldn't see why not.

So, the code stub demoing its not working is posted in a previous post in this thread, and I'm wondering if I somehow used the procedure wrong, or if there's a bug in it.

Dan

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu