EventTextAccepted returns true when RE filters out text.

Create issue
Issue #59 resolved
Former user created an issue

Automatic migration. Original reporter: "granx"

Client code might expect the EventTextAccepted to return false when all text entered was filtered out with a regular expression rule. It may be possible for clients to work around this issue by catching the filtered code in another callback, possibly the EventInvalidEntryAttempted ? This is a big change, and not a necessary one as there may exist alternative solutions, but possibly the event should return false when the RE filtered the text.

Reproducibility: always

Additional information: A user tried to filter out the "" character so that cegui did not handle this event and he could use this button press to close a console. He was keying off of the EventTextAccepted event. Maybe another event for character-by-character entry would have been better for him to subscribe. While the Editbox had the focus, it appeared as though cegui handled this event, so that his client code never had an opportunity to handle it.

Comments (2)

  1. Paul Turner

    Thanks for the report.

    The EventTextAccepted should only be fired when the user presses one of the enter, return or tab keys while the editbox is active and accepting input. The event is generated regardless of the content of the box and this is by design.

    For the issue that you describe, I think that the EventCharacterKey is more likely a source of error - here the event is indeed marked as handled by Editbox when rejected by the assigned RegEx. This is almost certainly unexpected behaviour, so I'll change this so that EventCharacterKey is only marked as handled by the Editbox if it was actually accepted into the edit text string. This modification should then allow catching keys rejected by the Editbox and using them for other purposes (like the console control as described).

  2. Paul Turner

    I have made a modification to the Editbox::onCharacter handler - it now only marks a key input as handled if the edit string was actually modified by the key press.

  3. Log in to comment