singerdmx / flutter-quill

Rich text editor for Flutter
https://pub.dev/packages/flutter_quill
MIT License
2.6k stars 840 forks source link

Is there some way to control the focusnode of quill toolbar? Why each QuillToolbar*Button need a focusnode? #2147

Closed MachineL102 closed 3 months ago

MachineL102 commented 3 months ago

Is there an existing issue for this?

The question

I have multiple Quill editors within a Stack widget:

In this scenario, if the focusNode of Quill editor 2 is the primary focusNode and I update controller2 to the QuillToolbar's controller, then when I click a QuillToolbarButton, the focusNode of Quill editor 1 becomes the primary focusNode. I expect that the QuillToolbarButton should not affect the focus management.

English is not my first language, so I apologize if there are any mistakes.

AtlasAutocode commented 3 months ago

Toolbar buttons act on the controller set when the button was created. The controller updates its document and that is shown in the editor that is attached to the controller. Focus is set to that editor.

if the focusNode of Quill editor 2 is the primary focusNode and I update controller2 to the QuillToolbar's controller

How are you updating the toolbar buttons to set them to controller2? It sounds like the toolbar buttons are still attached to controller1.

To get the effect you want you will need 2 editors, with 2 controllers and 2 toolbars. Simply show/hide whichever toolbar is needed for the editor that has the focus.

MachineL102 commented 3 months ago

ooo, you're right, i get it. Using the same number of toolbar corresponding to editor solve my problem, instead of just update the editor's controller. Thanks a lot~