@@ -315,52 +315,6 @@ private static int clamp(int min, int val, int max) {
315315 @ Override public Duration getMouseOverTextDelay () { return mouseOverTextDelay .get (); }
316316 @ Override public ObjectProperty <Duration > mouseOverTextDelayProperty () { return mouseOverTextDelay ; }
317317
318- private final BooleanProperty autoScrollOnDragDesired = new SimpleBooleanProperty (true );
319- public final void setAutoScrollOnDragDesired (boolean val ) { autoScrollOnDragDesired .set (val ); }
320- public final boolean isAutoScrollOnDragDesired () { return autoScrollOnDragDesired .get (); }
321-
322- private final Property <Consumer <MouseEvent >> onOutsideSelectionMousePress = new SimpleObjectProperty <>(e -> {
323- CharacterHit hit = hit (e .getX (), e .getY ());
324- moveTo (hit .getInsertionIndex (), SelectionPolicy .CLEAR );
325- });
326- public final void setOnOutsideSelectionMousePress (Consumer <MouseEvent > consumer ) { onOutsideSelectionMousePress .setValue (consumer ); }
327- public final Consumer <MouseEvent > getOnOutsideSelectionMousePress () { return onOutsideSelectionMousePress .getValue (); }
328-
329- private final Property <Consumer <MouseEvent >> onInsideSelectionMousePressRelease = new SimpleObjectProperty <>(e -> {
330- CharacterHit hit = hit (e .getX (), e .getY ());
331- moveTo (hit .getInsertionIndex (), SelectionPolicy .CLEAR );
332- });
333- public final void setOnInsideSelectionMousePressRelease (Consumer <MouseEvent > consumer ) { onInsideSelectionMousePressRelease .setValue (consumer ); }
334- public final Consumer <MouseEvent > getOnInsideSelectionMousePressRelease () { return onInsideSelectionMousePressRelease .getValue (); }
335-
336- private final Property <Consumer <Point2D >> onNewSelectionDrag = new SimpleObjectProperty <>(p -> {
337- CharacterHit hit = hit (p .getX (), p .getY ());
338- moveTo (hit .getInsertionIndex (), SelectionPolicy .ADJUST );
339- });
340- public final void setOnNewSelectionDrag (Consumer <Point2D > consumer ) { onNewSelectionDrag .setValue (consumer ); }
341- public final Consumer <Point2D > getOnNewSelectionDrag () { return onNewSelectionDrag .getValue (); }
342-
343- private final Property <Consumer <MouseEvent >> onNewSelectionDragEnd = new SimpleObjectProperty <>(e -> {
344- CharacterHit hit = hit (e .getX (), e .getY ());
345- moveTo (hit .getInsertionIndex (), SelectionPolicy .ADJUST );
346- });
347- public final void setOnNewSelectionDragEnd (Consumer <MouseEvent > consumer ) { onNewSelectionDragEnd .setValue (consumer ); }
348- public final Consumer <MouseEvent > getOnNewSelectionDragEnd () { return onNewSelectionDragEnd .getValue (); }
349-
350- private final Property <Consumer <Point2D >> onSelectionDrag = new SimpleObjectProperty <>(p -> {
351- CharacterHit hit = hit (p .getX (), p .getY ());
352- displaceCaret (hit .getInsertionIndex ());
353- });
354- public final void setOnSelectionDrag (Consumer <Point2D > consumer ) { onSelectionDrag .setValue (consumer ); }
355- public final Consumer <Point2D > getOnSelectionDrag () { return onSelectionDrag .getValue (); }
356-
357- private final Property <Consumer <MouseEvent >> onSelectionDrop = new SimpleObjectProperty <>(e -> {
358- CharacterHit hit = hit (e .getX (), e .getY ());
359- moveSelectedText (hit .getInsertionIndex ());
360- });
361- @ Override public final void setOnSelectionDrop (Consumer <MouseEvent > consumer ) { onSelectionDrop .setValue (consumer ); }
362- @ Override public final Consumer <MouseEvent > getOnSelectionDrop () { return onSelectionDrop .getValue (); }
363-
364318 private final ObjectProperty <IntFunction <? extends Node >> paragraphGraphicFactory = new SimpleObjectProperty <>(null );
365319 @ Override
366320 public void setParagraphGraphicFactory (IntFunction <? extends Node > factory ) { paragraphGraphicFactory .set (factory ); }
@@ -415,6 +369,60 @@ public Optional<Tuple2<Codec<PS>, Codec<SEG>>> getStyleCodecs() {
415369 @ Override
416370 public void setEstimatedScrollY (double value ) { virtualFlow .estimatedScrollYProperty ().setValue (value ); }
417371
372+ /* ********************************************************************** *
373+ * *
374+ * Mouse Behavior Hooks *
375+ * *
376+ * Hooks for overriding some of the default mouse behavior *
377+ * *
378+ * ********************************************************************** */
379+
380+ private final Property <Consumer <MouseEvent >> onOutsideSelectionMousePress = new SimpleObjectProperty <>(e -> {
381+ CharacterHit hit = hit (e .getX (), e .getY ());
382+ moveTo (hit .getInsertionIndex (), SelectionPolicy .CLEAR );
383+ });
384+ public final void setOnOutsideSelectionMousePress (Consumer <MouseEvent > consumer ) { onOutsideSelectionMousePress .setValue (consumer ); }
385+ public final Consumer <MouseEvent > getOnOutsideSelectionMousePress () { return onOutsideSelectionMousePress .getValue (); }
386+
387+ private final Property <Consumer <MouseEvent >> onInsideSelectionMousePressRelease = new SimpleObjectProperty <>(e -> {
388+ CharacterHit hit = hit (e .getX (), e .getY ());
389+ moveTo (hit .getInsertionIndex (), SelectionPolicy .CLEAR );
390+ });
391+ public final void setOnInsideSelectionMousePressRelease (Consumer <MouseEvent > consumer ) { onInsideSelectionMousePressRelease .setValue (consumer ); }
392+ public final Consumer <MouseEvent > getOnInsideSelectionMousePressRelease () { return onInsideSelectionMousePressRelease .getValue (); }
393+
394+ private final Property <Consumer <Point2D >> onNewSelectionDrag = new SimpleObjectProperty <>(p -> {
395+ CharacterHit hit = hit (p .getX (), p .getY ());
396+ moveTo (hit .getInsertionIndex (), SelectionPolicy .ADJUST );
397+ });
398+ public final void setOnNewSelectionDrag (Consumer <Point2D > consumer ) { onNewSelectionDrag .setValue (consumer ); }
399+ public final Consumer <Point2D > getOnNewSelectionDrag () { return onNewSelectionDrag .getValue (); }
400+
401+ private final Property <Consumer <MouseEvent >> onNewSelectionDragEnd = new SimpleObjectProperty <>(e -> {
402+ CharacterHit hit = hit (e .getX (), e .getY ());
403+ moveTo (hit .getInsertionIndex (), SelectionPolicy .ADJUST );
404+ });
405+ public final void setOnNewSelectionDragEnd (Consumer <MouseEvent > consumer ) { onNewSelectionDragEnd .setValue (consumer ); }
406+ public final Consumer <MouseEvent > getOnNewSelectionDragEnd () { return onNewSelectionDragEnd .getValue (); }
407+
408+ private final Property <Consumer <Point2D >> onSelectionDrag = new SimpleObjectProperty <>(p -> {
409+ CharacterHit hit = hit (p .getX (), p .getY ());
410+ displaceCaret (hit .getInsertionIndex ());
411+ });
412+ public final void setOnSelectionDrag (Consumer <Point2D > consumer ) { onSelectionDrag .setValue (consumer ); }
413+ public final Consumer <Point2D > getOnSelectionDrag () { return onSelectionDrag .getValue (); }
414+
415+ private final Property <Consumer <MouseEvent >> onSelectionDrop = new SimpleObjectProperty <>(e -> {
416+ CharacterHit hit = hit (e .getX (), e .getY ());
417+ moveSelectedText (hit .getInsertionIndex ());
418+ });
419+ @ Override public final void setOnSelectionDrop (Consumer <MouseEvent > consumer ) { onSelectionDrop .setValue (consumer ); }
420+ @ Override public final Consumer <MouseEvent > getOnSelectionDrop () { return onSelectionDrop .getValue (); }
421+
422+ // not a hook, but still plays a part in the default mouse behavior
423+ private final BooleanProperty autoScrollOnDragDesired = new SimpleBooleanProperty (true );
424+ public final void setAutoScrollOnDragDesired (boolean val ) { autoScrollOnDragDesired .set (val ); }
425+ public final boolean isAutoScrollOnDragDesired () { return autoScrollOnDragDesired .get (); }
418426
419427 /* ********************************************************************** *
420428 * *
@@ -615,7 +623,7 @@ public GenericStyledArea(
615623 this .applyParagraphStyle = applyParagraphStyle ;
616624 this .segmentOps = segmentOps ;
617625
618- undoManager = UndoUtils .createUndoManager (this );
626+ undoManager = UndoUtils .defaultUndoManager (this );
619627
620628 // allow tab traversal into area
621629 setFocusTraversable (true );
@@ -647,13 +655,6 @@ public GenericStyledArea(
647655 IntUnaryOperator cellLength = i -> virtualFlow .getCell (i ).getNode ().getLineCount ();
648656 navigator = new TwoLevelNavigator (cellCount , cellLength );
649657
650- // relayout the popup when any of its settings values change (besides the caret being dirty)
651- EventStream <?> popupAlignmentDirty = invalidationsOf (popupAlignmentProperty ());
652- EventStream <?> popupAnchorAdjustmentDirty = invalidationsOf (popupAnchorAdjustmentProperty ());
653- EventStream <?> popupAnchorOffsetDirty = invalidationsOf (popupAnchorOffsetProperty ());
654- EventStream <?> popupDirty = merge (popupAlignmentDirty , popupAnchorAdjustmentDirty , popupAnchorOffsetDirty );
655- subscribeTo (popupDirty , x -> layoutPopup ());
656-
657658 viewportDirty = merge (
658659 // no need to check for width & height invalidations as scroll values update when these do
659660
@@ -677,17 +678,6 @@ public GenericStyledArea(
677678
678679 visibleParagraphs = LiveList .map (virtualFlow .visibleCells (), c -> c .getNode ().getParagraph ()).suspendable ();
679680
680- // Adjust popup anchor by either a user-provided function,
681- // or user-provided offset, or don't adjust at all.
682- Val <UnaryOperator <Point2D >> userOffset = Val .map (
683- popupAnchorOffsetProperty (),
684- offset -> anchor -> anchor .add (offset ));
685- _popupAnchorAdjustment =
686- Val .orElse (
687- popupAnchorAdjustmentProperty (),
688- userOffset )
689- .orElseConst (UnaryOperator .identity ());
690-
691681 final Suspendable omniSuspendable = Suspendable .combine (
692682 beingUpdated , // must be first, to be the last one to release
693683
@@ -703,6 +693,26 @@ public GenericStyledArea(
703693 .subscribe (evt -> Event .fireEvent (this , evt ));
704694
705695 new StyledTextAreaBehavior (this );
696+
697+ // Code below this point is deprecated Popup API. It will be removed in the future
698+
699+ // relayout the popup when any of its settings values change (besides the caret being dirty)
700+ EventStream <?> popupAlignmentDirty = invalidationsOf (popupAlignmentProperty ());
701+ EventStream <?> popupAnchorAdjustmentDirty = invalidationsOf (popupAnchorAdjustmentProperty ());
702+ EventStream <?> popupAnchorOffsetDirty = invalidationsOf (popupAnchorOffsetProperty ());
703+ EventStream <?> popupDirty = merge (popupAlignmentDirty , popupAnchorAdjustmentDirty , popupAnchorOffsetDirty );
704+ subscribeTo (popupDirty , x -> layoutPopup ());
705+
706+ // Adjust popup anchor by either a user-provided function,
707+ // or user-provided offset, or don't adjust at all.
708+ Val <UnaryOperator <Point2D >> userOffset = Val .map (
709+ popupAnchorOffsetProperty (),
710+ offset -> anchor -> anchor .add (offset ));
711+ _popupAnchorAdjustment =
712+ Val .orElse (
713+ popupAnchorAdjustmentProperty (),
714+ userOffset )
715+ .orElseConst (UnaryOperator .identity ());
706716 }
707717
708718 /* ********************************************************************** *
0 commit comments