Ed Leafe wrote:
> On Oct 5, 2010, at 1:33 PM, OKB (not okblacke) wrote:
>
>> The SelectedText property doesn't work, because nothing is
>> selected. I want to inspect the text at the insertion point
>> itself during normal text input, so I can decide as each character
>> is entered whether or not to allow it. (SelectionStart and
>> SelectionEnd just return the same value as InsertionPosition, so
>> they're not useful to me either.)
>
> I guess my question is: when there is no selection, do you
> need...
>
> a) the character immediately before the insertion point
> b) the character immediately after the insertion point
> c) n character(s) immediately before the insertion point
> d) n character(s) immediately after the insertion point
> e) n,m character(s) immediately before/after the insertion point
I would like to be able to get all of those (which I guess means e,
since it subsumes the rest).
> We'd also need to define what would be returned in the case
> where there is selected text.
Yeah, I was wondering about that. It looks like when there is
selected text, there is still an insertion point. If I select some text
by dragging to the right, I can see the flashing cursor at the right
edge of my selection, or if I drag left I can see the cursor at the left
edge, so if it just returned text relative to that insertsion point that
would seem fine to me.
>> Incidentally, I had hoped I could achieve a similar effect with
>> some sort of validation, but I can't figure out how to do that
>> without creating a bizObj and connecting the GUI to a database,
>> and I'd rather not drag in all that complexity. Is there a way to
>> just specify a function that validates data in a particular text
>> field?
>
> You could always override the form's validateField() method,
> using something like this:
>
> def validateField(self, ctrl):
> if ctrl is self.MyEditBox:
> <do some validation stuff>
> else:
> super(dForm, self).validateField(ctrl)
Ah, thanks. I had been looking for such a method on the EditBox
itself, not the form. However, I can't seem to make it work.
What do I do in that method to declare input invalid?
Maybe describing my overall problem will be useful, because it may
be that my inexperience with Dabo is causing me to miss a better
solution. What I want is to be able to intercept any attempt to edit
the text in the box, and have "veto power" over it. I want to ask, for
any edit: will this edit cause the text to no longer match a certain
pattern? If so, I want to disallow the edit entirely and just leave the
text in the edit box unaffected. (More specifically, I am trying to let
the user edit a preloaded text only as far as adding and removing
newlines; they should not be able to change the text in any other way.)
I would ideally like this to work for any kind of edit attempt (i.e.,
selecting text and deleting it, deleting from the insertion point,
typing at the insertion point, whatever), but if it just works for
keyboard edit that would be workable.
At first I thought of doing this by validating the EditBox content.
When I couldn't figure out how to do that I thought I'd try to hack it
by intercepting keystrokes that would cause the content to go into an
invalid state. Now it seems I may be able to validate it after all, but
I can't figure out how to actually say "this is invalid, don't let the
user enter it". What is the best solution for this desired behavior?
Thanks for your help,
--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]