Skip to content

Commit

Permalink
fix: keep erasing after releasing stylus button
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebraVogel94349 authored and adil192 committed Jul 9, 2023
1 parent 80ce68d commit a0001cd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/pages/editor/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class EditorState extends State<Editor> {
Tool? tmpTool;
/// If the stylus button is pressed.
bool stylusButtonPressed = false;
// If the eraser is selected because the stylus button has been pressed
bool currentlyErasing = false;

@override
void initState() {
Expand Down Expand Up @@ -592,6 +594,12 @@ class EditorState extends State<Editor> {
));
} else if (currentTool is Eraser) {
final erased = (currentTool as Eraser).onDragEnd();
if (currentlyErasing){
currentlyErasing = false;
currentTool = tmpTool!;
tmpTool = null;
setState(() {});
}
if (erased.isEmpty) return;
history.recordChange(EditorHistoryItem(
type: EditorHistoryItemType.erase,
Expand Down Expand Up @@ -653,11 +661,7 @@ class EditorState extends State<Editor> {
}
currentTool = Eraser();
setState(() {});
} else {
if (tmpTool == null) return;
currentTool = tmpTool!;
tmpTool = null;
setState(() {});
currentlyErasing = true;
}
}

Expand Down

0 comments on commit a0001cd

Please sign in to comment.