|
1 | 1 | package haxe.ui.containers;
|
2 | 2 |
|
| 3 | +import haxe.ui.constants.MouseButton; |
3 | 4 | import haxe.ui.actions.ActionType;
|
4 | 5 | import haxe.ui.behaviours.Behaviour;
|
5 | 6 | import haxe.ui.behaviours.DataBehaviour;
|
@@ -49,6 +50,7 @@ class ScrollView extends InteractiveComponent implements IScroller {
|
49 | 50 | @:clonable @:behaviour(VScrollPageSize) public var vscrollPageSize:Float;
|
50 | 51 | @:clonable @:behaviour(VScrollThumbSize) public var vscrollThumbSize:Null<Float>;
|
51 | 52 | @:clonable @:behaviour(ThumbSize) public var thumbSize:Null<Float>;
|
| 53 | + @:clonable @:behaviour(DefaultBehaviour, MouseButton.LEFT) public var scrollMouseButton:MouseButton; |
52 | 54 | @:clonable @:behaviour(ScrollModeBehaviour, ScrollMode.DRAG) public var scrollMode:ScrollMode;
|
53 | 55 | @:clonable @:behaviour(ScrollPolicyBehaviour) public var scrollPolicy:ScrollPolicy;
|
54 | 56 | @:clonable @:behaviour(HScrollPolicyBehaviour) public var horizontalScrollPolicy:ScrollPolicy;
|
@@ -689,9 +691,13 @@ class ScrollViewEvents extends haxe.ui.events.Events {
|
689 | 691 | }
|
690 | 692 |
|
691 | 693 | if (_scrollview.scrollMode == ScrollMode.DRAG || _scrollview.scrollMode == ScrollMode.INERTIAL) {
|
692 |
| - registerEvent(MouseEvent.MOUSE_DOWN, onMouseDown); |
693 |
| - } else if (hasEvent(MouseEvent.MOUSE_DOWN, onMouseDown)) { |
694 |
| - unregisterEvent(MouseEvent.MOUSE_DOWN, onMouseDown); |
| 694 | + registerEvent(MouseEvent.MIDDLE_MOUSE_DOWN, onMiddleMouseDown); |
| 695 | + registerEvent(MouseEvent.MOUSE_DOWN, onLeftMouseDown); |
| 696 | + registerEvent(MouseEvent.RIGHT_MOUSE_DOWN, onRightMouseDown); |
| 697 | + } else if (hasEvent(MouseEvent.MOUSE_DOWN, onLeftMouseDown)) { |
| 698 | + unregisterEvent(MouseEvent.MIDDLE_MOUSE_DOWN, onMiddleMouseDown); |
| 699 | + unregisterEvent(MouseEvent.MOUSE_DOWN, onLeftMouseDown); |
| 700 | + unregisterEvent(MouseEvent.RIGHT_MOUSE_DOWN, onRightMouseDown); |
695 | 701 | }
|
696 | 702 |
|
697 | 703 | if (_scrollview.hasEvent(UIEvent.SHOWN) == false) {
|
@@ -736,7 +742,9 @@ class ScrollViewEvents extends haxe.ui.events.Events {
|
736 | 742 | vscroll.unregisterEvent(ScrollEvent.SCROLL, onVScrollScroll);
|
737 | 743 | }
|
738 | 744 |
|
739 |
| - unregisterEvent(MouseEvent.MOUSE_DOWN, onMouseDown); |
| 745 | + unregisterEvent(MouseEvent.MIDDLE_MOUSE_DOWN, onMiddleMouseDown); |
| 746 | + unregisterEvent(MouseEvent.RIGHT_MOUSE_DOWN, onRightMouseDown); |
| 747 | + unregisterEvent(MouseEvent.MOUSE_DOWN, onLeftMouseDown); |
740 | 748 | unregisterEvent(MouseEvent.MOUSE_WHEEL, onMouseWheel);
|
741 | 749 | unregisterEvent(UIEvent.SHOWN, onShown);
|
742 | 750 | unregisterEvent(UIEvent.COMPONENT_ADDED, onComponentAdded);
|
@@ -807,6 +815,27 @@ class ScrollViewEvents extends haxe.ui.events.Events {
|
807 | 815 | private function onVScrollScroll(event:UIEvent) {
|
808 | 816 | _target.dispatch(new ScrollEvent(ScrollEvent.SCROLL));
|
809 | 817 | }
|
| 818 | + |
| 819 | + @:access(haxe.ui.core.Component) |
| 820 | + private function onLeftMouseDown(event:MouseEvent) { |
| 821 | + if (_scrollview.scrollMouseButton == MouseButton.LEFT) { |
| 822 | + onMouseDown(event); |
| 823 | + } |
| 824 | + } |
| 825 | + |
| 826 | + @:access(haxe.ui.core.Component) |
| 827 | + private function onMiddleMouseDown(event:MouseEvent) { |
| 828 | + if (_scrollview.scrollMouseButton == MouseButton.MIDDLE) { |
| 829 | + onMouseDown(event); |
| 830 | + } |
| 831 | + } |
| 832 | + |
| 833 | + @:access(haxe.ui.core.Component) |
| 834 | + private function onRightMouseDown(event:MouseEvent) { |
| 835 | + if (_scrollview.scrollMouseButton == MouseButton.RIGHT) { |
| 836 | + onMouseDown(event); |
| 837 | + } |
| 838 | + } |
810 | 839 |
|
811 | 840 | private var _offset:Point;
|
812 | 841 | private static inline var INERTIAL_TIME_CONSTANT:Int = 325;
|
@@ -867,6 +896,8 @@ class ScrollViewEvents extends haxe.ui.events.Events {
|
867 | 896 | }
|
868 | 897 |
|
869 | 898 | Screen.instance.registerEvent(MouseEvent.MOUSE_MOVE, onMouseMove);
|
| 899 | + Screen.instance.registerEvent(MouseEvent.MIDDLE_MOUSE_UP, onMouseUp); |
| 900 | + Screen.instance.registerEvent(MouseEvent.RIGHT_MOUSE_UP, onMouseUp); |
870 | 901 | Screen.instance.registerEvent(MouseEvent.MOUSE_UP, onMouseUp);
|
871 | 902 | }
|
872 | 903 |
|
@@ -967,6 +998,8 @@ class ScrollViewEvents extends haxe.ui.events.Events {
|
967 | 998 |
|
968 | 999 | private function onMouseUp(event:MouseEvent) {
|
969 | 1000 | Screen.instance.unregisterEvent(MouseEvent.MOUSE_MOVE, onMouseMove);
|
| 1001 | + Screen.instance.unregisterEvent(MouseEvent.MIDDLE_MOUSE_UP, onMouseUp); |
| 1002 | + Screen.instance.unregisterEvent(MouseEvent.RIGHT_MOUSE_UP, onMouseUp); |
970 | 1003 | Screen.instance.unregisterEvent(MouseEvent.MOUSE_UP, onMouseUp);
|
971 | 1004 |
|
972 | 1005 | if (_scrollview.scrollMode == ScrollMode.INERTIAL) {
|
|
0 commit comments