Browse Source
[macOS] Fixes stuck mouse buttons after drag (#17035)
* Reset pressed mouse buttons on drag on macOS
* Make draggable borders easier to click in ControlCatalog
pull/17101/head
Julien Lebosquain
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
24 additions and
9 deletions
-
native/Avalonia.Native/src/OSX/AvnView.h
-
native/Avalonia.Native/src/OSX/AvnView.mm
-
native/Avalonia.Native/src/OSX/WindowBaseImpl.mm
-
samples/ControlCatalog/Pages/DragAndDropPage.xaml
|
|
|
@ -19,6 +19,7 @@ |
|
|
|
-(AvnPoint) translateLocalPoint:(AvnPoint)pt; |
|
|
|
-(void) onClosed; |
|
|
|
-(void) setModifiers:(NSEventModifierFlags)modifierFlags; |
|
|
|
-(void) resetPressedMouseButtons; |
|
|
|
|
|
|
|
-(AvnPlatformResizeReason) getResizeReason; |
|
|
|
-(void) setResizeReason:(AvnPlatformResizeReason)reason; |
|
|
|
|
|
|
|
@ -485,6 +485,15 @@ |
|
|
|
_modifierState = [self getModifiers:modifierFlags]; |
|
|
|
} |
|
|
|
|
|
|
|
- (void)resetPressedMouseButtons |
|
|
|
{ |
|
|
|
_isLeftPressed = false; |
|
|
|
_isRightPressed = false; |
|
|
|
_isMiddlePressed = false; |
|
|
|
_isXButton1Pressed = false; |
|
|
|
_isXButton2Pressed = false; |
|
|
|
} |
|
|
|
|
|
|
|
- (void)flagsChanged:(NSEvent *)event |
|
|
|
{ |
|
|
|
auto newModifierState = [self getModifiers:[event modifierFlags]]; |
|
|
|
|
|
|
|
@ -430,6 +430,7 @@ HRESULT WindowBaseImpl::BeginDragAndDropOperation(AvnDragDropEffects effects, Av |
|
|
|
op |= NSDragOperationLink; |
|
|
|
if ((ieffects & (int) AvnDragDropEffects::Move) != 0) |
|
|
|
op |= NSDragOperationMove; |
|
|
|
[View resetPressedMouseButtons]; |
|
|
|
[View beginDraggingSessionWithItems:@[dragItem] event:nsevent |
|
|
|
source:CreateDraggingSource((NSDragOperation) op, cb, sourceHandle)]; |
|
|
|
return S_OK; |
|
|
|
|
|
|
|
@ -1,6 +1,16 @@ |
|
|
|
<UserControl x:Class="ControlCatalog.Pages.DragAndDropPage" |
|
|
|
xmlns="https://github.com/avaloniaui" |
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|
|
|
|
|
|
|
<UserControl.Styles> |
|
|
|
<Style Selector="Border.draggable"> |
|
|
|
<Setter Property="Background" Value="Transparent" /> |
|
|
|
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColor}" /> |
|
|
|
<Setter Property="BorderThickness" Value="2" /> |
|
|
|
<Setter Property="Padding" Value="16" /> |
|
|
|
</Style> |
|
|
|
</UserControl.Styles> |
|
|
|
|
|
|
|
<StackPanel Orientation="Vertical" Spacing="4"> |
|
|
|
<TextBlock Classes="h2">Example of Drag+Drop capabilities</TextBlock> |
|
|
|
|
|
|
|
@ -8,21 +18,15 @@ |
|
|
|
<StackPanel Margin="8" |
|
|
|
MaxWidth="160"> |
|
|
|
<Border Name="DragMeText" |
|
|
|
Padding="16" |
|
|
|
BorderBrush="{DynamicResource SystemAccentColor}" |
|
|
|
BorderThickness="2"> |
|
|
|
Classes="draggable"> |
|
|
|
<TextBlock Name="DragStateText" TextWrapping="Wrap">Drag Me (text)</TextBlock> |
|
|
|
</Border> |
|
|
|
<Border Name="DragMeFiles" |
|
|
|
Padding="16" |
|
|
|
BorderBrush="{DynamicResource SystemAccentColor}" |
|
|
|
BorderThickness="2"> |
|
|
|
Classes="draggable"> |
|
|
|
<TextBlock Name="DragStateFiles" TextWrapping="Wrap">Drag Me (files)</TextBlock> |
|
|
|
</Border> |
|
|
|
<Border Name="DragMeCustom" |
|
|
|
Padding="16" |
|
|
|
BorderBrush="{DynamicResource SystemAccentColor}" |
|
|
|
BorderThickness="2"> |
|
|
|
Classes="draggable"> |
|
|
|
<TextBlock Name="DragStateCustom" TextWrapping="Wrap">Drag Me (custom)</TextBlock> |
|
|
|
</Border> |
|
|
|
</StackPanel> |
|
|
|
|