Skip to content

Simplify API for canvas event handlers #1713

@freakboy3742

Description

@freakboy3742

What is the problem or limitation you are having?

The current implementation of event handlers on toga.Canvas has some interesting quirks.

  1. It allows for a "double click drag"... and I'm not even sure what that would mean.
  2. It is closely bound to a mouse-driven implementation (in particular, it references alt and double click)

Describe the solution you'd like

It might make more sense to drop the clicks argument to the event handlers, and have separate events for:

  • on_press and on_alt_press
  • on_activate (i.e., double click) and on_alt_activate
  • on_drag
  • on_release and on_alt_release

That would make events a lot closer to their "functional" purpose, rather than tying them to a specific implementation (e.g. - what is a double click on a touchscreen?) It would de-emphasize the importance of clicks, especially in the context of drag; and it would put the focus on press/activate, rather than release events.

The general advice would be to avoid using "alt" press (or, at least, provide different ways of accessing that functionality); this is consistent with the sort of approach taken by the macOS style guide, which allows for "right click" actions, but encourages that to be an interface for "power users".

This would simplify the winforms and GTK implementations (which currently need to do imml-level stateful tracking of the current click state), and makes the API for mobile canvas less of a band-aid (as we can use long-press or force-press events for "activate").

Describe alternatives you've considered

Do nothing. The current API works; it's just not ideal.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features, or improvements to existing features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions