Skip to content

Conversation

@microbit-matt-hillsdon
Copy link
Contributor

@microbit-matt-hillsdon microbit-matt-hillsdon commented Mar 4, 2025

Instead hide/show cursor/passive focus indicator on the relevant focus changes.

Fixes #263

I totally might be missing a reason why we can't do this. But if we can it seems like a clear win.

Demo: https://simplify-marked-node.blockly-keyboard-experimentation.pages.dev/

Instead hide/show cursor/passive focus indicator on the relevant focus changes.

Fixes RaspberryPiFoundation#263
@microbit-matt-hillsdon microbit-matt-hillsdon requested a review from a team as a code owner March 4, 2025 17:33
@microbit-matt-hillsdon microbit-matt-hillsdon requested review from cpcallen and removed request for a team March 4, 2025 17:33
@microbit-matt-hillsdon
Copy link
Contributor Author

Note to self: if we merge this then the same logic needs to be run in the external toolbox scenario.

@rachel-fenichel rachel-fenichel self-requested a review March 4, 2025 18:35
@rachel-fenichel rachel-fenichel self-assigned this Mar 4, 2025
Copy link
Collaborator

@cpcallen cpcallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine (though note comments below). Would like to verify that this works in practice before merging, though, as @rachel-fenichel had some concerns.

const cursor = workspace.getCursor();
if (cursor) {
this.passiveFocusIndicator.show(cursor.getCurNode());
cursor.hide();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be noted that (contrary to expectations) Marker.prototype.hide does not cause the cursor to be persistently hidden, but only hides the marker SVG, and only until the next time a render occurs.

Marker SVG is used for denoting position of cursor when it is on a connection or on the workspace (or on a whole-stack node, though these are only currently accessible via the context-out shortcut which will probably go away very soon).

So AFAICT this won't hide the cursor if it's on a block, and if it isn't on a block then it will be hidden but may reappear unexpectedly if something causes a render to occur.

Probably not a big deal, given that the existing code does exactly the same thing, though I do wonder if it might be better to hide the cursor before showing the passive focus indicator (here and in focusFlyout).

Comment on lines +445 to +446
this.passiveFocusIndicator.show(cursor.getCurNode());
cursor.hide();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it still work if you call cursor.hide() before passiveFocusIndicator.show? It would seem more tidy to do it in that order.

@cpcallen
Copy link
Collaborator

cpcallen commented Mar 7, 2025

OK, I played with this for a while and couldn't find any situations in which the cursor was not in the expected place.

LGTM.

@microbit-matt-hillsdon
Copy link
Contributor Author

Closing in favour of discussion around #326

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.

Paste over shadow block only works on the second attempt via menu

3 participants