Skip to content

Answer a right click the way a long press is answered - #930

Open
JingMatrix wants to merge 1 commit into
masterfrom
fix-secondary-click
Open

Answer a right click the way a long press is answered#930
JingMatrix wants to merge 1 commit into
masterfrom
fix-secondary-click

Conversation

@JingMatrix

Copy link
Copy Markdown
Owner

A tablet with a keyboard case is a pointer device, and the way to ask a row for its menu with a pointer is the secondary button — a right click, or a two-finger tap on the touchpad. combinedClickable reads a press from any button as an ordinary tap and finds a long press only by timing a held finger, so a right click did whatever a left click does: opened a module's scope instead of its menu, toggled an app instead of offering to re-optimize it.

The View-based manager never had to say this — a View opens its registered context menu on a secondary press by itself. It did that badly: the menu was built from the row under the pointer but acted on a field only the long press listener wrote, so it opened against whichever row was held last. That is what #644 reported; Compose changed the symptom, not the cause.

So the press is handed to the same lambda the long press runs, watched on the initial pass — ahead of the one foundation listens on — and consumed, which is what keeps the click from landing.

Module rows and their icons, apps in a scope, contributors on the home screen. Nothing changes for a finger.

Fixes #644.

A tablet with a keyboard case is a pointer device, and the way to ask a row for its menu with a
pointer is the secondary button: a right click, or a two-finger tap on the touchpad. Nothing in the
manager answered it. combinedClickable reads a press from any button as the beginning of an ordinary
tap and finds a long press only by timing a held finger, so a right click did whatever a left click
does -- opened a module's scope instead of its menu, toggled an app instead of offering to
re-optimize it -- and what the hold was for could not be reached at all.

The View-based manager never had to say any of this. A View shows its registered context menu on a
secondary press by itself, which is why the gesture worked at all before the manager was written in
Compose. It worked badly: the menu was built from the row under the pointer but acted on a field
that only the long press listener wrote, so it opened against whichever row had been held last, or
did nothing when none had been (#644).

So the press is caught and handed to the same lambda the long press runs, the two gestures meaning
the same thing -- one asked with a finger, one asked with a pointer. It is watched on the initial
pass, ahead of the pass foundation listens on, and every event from the moment the button is
reported held is consumed, which is also what keeps the click from landing: foundation asks for a
press nothing else has taken, and for a release nothing else has taken. The action runs on the way
down rather than on the release, which is when a View opens its context menu too.

The rows that gain it are the ones a long press already meant something on: a module and its icon in
the shared row, an app in a module's scope, and a contributor's avatar and their name on the home
screen. Nothing changes for a finger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secondary tap does not work in modules list correctly

1 participant