Skip to content

Textbox KeyPressEventHandler e.Handled = true doesn't work #12

Closed

Description

@itg-assistant

Takashi Arikuma asked 2016-05-01 03:08:00 UTC

Textbox works fine, but if I try to cancel some char input with

e.Handled = true

it doesn't work.

Can I handle events inside objects with JavaScript?

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Frank (ITG) answered 2016-05-01 19:06:18 UTC

    Thanks Takashi,

    we have logged this bug in our tracking system as WJ-7225.
    We will post a new answer here when it is resolved.

  2. added
    BugSomething is broken or behaving unexpectedly.
    on Jun 12, 2026
  3. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-05-01 21:42:00 UTC

    Hello Takashi,

    Keyboard events, like all events in Wisej, are routed to the server asynchronously. The Handled property is useful on the server side when managing the OnKeyDown/Up/Press events to signal that a child has handled the key. However, this has no effect on the client,  unless you actually change the Text property to trigger a client update - I wouldn't recommend this approach unless really necessary.

    If you want to handle keys as they are typed and be able to stop the browser from processing the key you have to do it on the client using the JavaScript provider. It's quite easy with Wisej. I have attached a sample project for you to use as a reference and a screen shot below of the script editor.

    Download the sample

    • Drop the JavaScript component on the page or window. This will add the JavaScript and JavaScriptSource property to all controls.

    • You can either type the javascript code in JavaScript, or select a .js file in JavaScriptSource.

    • The javascript runs in the widget's context: this = widget, see code above. It runs only once when  the page is loaded or reloaded.

    Keeping the script above as a reference, we attach the "keypress" handler and handle the event. To stop it from both bubbling and "defaulting" use e.stop(). Otherwise you can use e.stopBubbling() and e.preventDefault().

    When you work directly in javascript we enter the qooxdoo realm. The full API is here: http://demo.qooxdoo.org/current/apiviewer/#qx

  4. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    ITG Admin answered 2016-05-02 13:21:01 UTC

    I’d like to add that in Wisej there are other ways to invoke javascript from the server in addition to the JavaScript provider.

    You can call Invoke() on any control and pass either a full script or a function name and arguments. See the overloads. The script always runs in the context of the control you invoked it on: “this” refers to the javascript widget. i.e. this.button1.Invoke(“hide”) will hide the client representation of the button.

    Scripts are always run last in the request/response cycle.

    There is also a web method callback system from JavaScript – call the server from the client marking an instance method [WebMethod] – and Wisej builds an entire object model on the client side under window.App. But this is a topic for the documentation and an example.

  5. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Ngabo Adrian answered 2022-07-07 13:00:35 UTC

    Hello Luca,
    Thank you for your support. Can the Sample that you talked about up on this issue be available once again? I’ve tried to download it but it seems its not there! Can you provide it for us again?
    Thank you
    Adrian

  6. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Frank (ITG) answered 2022-07-07 13:21:26 UTC

    Ngabo, please check out our sample here: https://github.com/iceteagroup/wisej-examples/tree/3.0/KeyboardHandling
    Best regards, Frank

  7. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Ngabo Adrian answered 2022-07-07 15:06:22 UTC

    Its alright, Thank you very much. I’ve seen it. Let me go through it.
    Adrian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is broken or behaving unexpectedly.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions