Textbox custom filter

Started by mr nick, November 09, 2009, 06:04:11 AM

Previous topic - Next topic

mr nick

I have a textbox on a dialog and I want to be able to allow all characters apart from lowercase and it must be multi-line. From the standard selections this isn't possible so it looks like I'd need to use a custom filter but this would need me to enter every keyboard character into a string which seems a little long-handed. Is there a slicker way to do this? I had looked at just forcing all typed text to uppercase but this results in the cursor being forced to the front of the text with every keypress so you actually end up typing backwards. I then thought about just repositioning the cursor to the end of the text which works OK provided you don't need to edit any text such as adding a missing word as the cursor keeps moving to the end. I could work around this if there were a way of determining the cursor position within the textbox but from what I can ascertain there is no way of extracting this info.

Can anyone give me a hint on a clean way of reaching my goal or am I just going to have to create a custom filter string with every keyboard character in it?

owenwengerd

I think GetSel might return your cursor position, but by far the simplest solutin would be to just convert the entered text to upper case at the point of use. Alternatively, an OnKillFocus handler could perform the conversion.
Owen Wengerd (Outside The Box) / ManuSoft

mr nick

I tried getsel but that only returns selected characters so always returns (0 0) as there is no actual selection made. I also tried the case-conversion but I detailed the problems this gives when trying to add missing characters or words - unless there is a way of converting the case that I don't know of - the method I've tried is this:

(dcl_Control_SetText mydialog_txtbox1 (strcase (dcl_Control_GetText mydialog_txtbox1)))

owenwengerd

What I meant was to convert the case wherever you use the text without updating the textbox itself.
Owen Wengerd (Outside The Box) / ManuSoft

mr nick

Quote from: owenwengerd on November 09, 2009, 10:25:36 AM
What I meant was to convert the case wherever you use the text without updating the textbox itself.

Ah, gotcha. Unfortunately I used to do this but then had people complaining that their text wasn't coming out as they entered it - despite the fact that it's a company standard that we don't use lowercase text in drawings. So now I have to spoonfeed people with exact stuff or I know I will get someone complaining even though it's caused by their own stupidity misunderstanding.  ::)

owenwengerd

Then I would try doing the updating from the OnKillFocus handler. Otherwise, you may just have to settle for the very long filter.
Owen Wengerd (Outside The Box) / ManuSoft