Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor disappears if clicking on empty space #38

Open
JCKodel opened this issue Dec 19, 2021 · 0 comments
Open

Cursor disappears if clicking on empty space #38

JCKodel opened this issue Dec 19, 2021 · 0 comments

Comments

@JCKodel
Copy link

JCKodel commented Dec 19, 2021

Video: https://vimeo.com/658396463/c4966aba27

My scenario: I'm doing a colour button on the toolbar using ZDropdownButton<Color>. After setting the text style, if I touch anywhere in the editor, except another text, the cursor just vanishes. It continues to accept input, but the cursor is invisible.

The cursor only become visible again if I press [Enter] or touch on another text.

On the video, you can see the cursor briefly disappears after I turn the word Color blue (that's because I touch the test word afterwards). Then, when colouring another word and touching on the empty editor space, notice how the cursor vanishes and never returns (until I touch a word or press [Enter] on the keyboard).

This is my toolbar button (with a modified ZDropdownButton class so the button don't get 110 pixels of width):

ZDropdownButton<Color>(
  child: Icon(Remix.font_color, color: _selectedColor),
  initialValue: _selectedColor ?? theme.colorScheme.onSurface,
  items: _colors,
  onSelected: (color) => _editorController.formatSelection(NotusAttribute.color.fromInt(color.value)),
),

The current color is tracked by:

_editorController.addListener(() {
  final selectionStyle = _editorController.getSelectionStyle();
  final colorAttribute = selectionStyle.get(NotusAttribute.color);

  if (colorAttribute != null) {
    setState(() => _selectedColor = Color(colorAttribute.value!));
  }

  final backgroundColorAttribute = selectionStyle.get(NotusAttribute.backgroundColor);

  if (backgroundColorAttribute != null) {
    setState(() => _selectedBackgroundColor = Color(backgroundColorAttribute.value!));
  }
});

The colours itself are only the current light/dark theme + Material primaries + black and white:

_colors = [
  PopupMenuItem(child: SizedBox(width: 80, height: 16, child: Placeholder(color: widget.defaultTextColor)), value: widget.defaultTextColor),
  ...Colors.primaries.map(
    (color) => PopupMenuItem(
      child: Container(width: 80, height: 16, color: color),
      value: color,
    ),
  ),
  PopupMenuItem(child: Container(width: 80, height: 16, color: Colors.black), value: Colors.black),
  PopupMenuItem(child: Container(width: 80, height: 16, color: Colors.white), value: Colors.white),
];
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

No branches or pull requests

1 participant