Skip to content

Commit 71ab182

Browse files
committed
CHANGED: Canvas drag default key bindings restored
In the default key bindings, the behavior of `ctrl+left mouse button` is described as follows: - If have elements are selected, execute `DnD` - If no element is selected, execute `canvas drag`
1 parent 18ced51 commit 71ab182

File tree

6 files changed

+76
-67
lines changed

6 files changed

+76
-67
lines changed

documentation/mdbook_asciio/src/SUMMARY.md

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- [Installation](guide/installation.md)
1010

1111
- [Asciio's interface](Interface.md)
12-
- [Tabs](tabs.md)
12+
- [Tabs](tabs.md)
1313

1414
- [Unicode support](unicode_support.md)
1515

@@ -42,7 +42,7 @@
4242
- [Mouse](editing/mouse.md)
4343
- [Cloning](editing/cloning.md)
4444
- [Stencils and "Drag and Drop"](editing/drag_drop.md)
45-
- [Changing element attributes](editing/changing_element_attributes.md)
45+
- [Changing element attributes](editing/changing_element_attributes.md)
4646

4747
- [Export/Save](exporting.md)
4848
- [Asciio format](export/asciio.md)
@@ -64,7 +64,7 @@
6464
- [Git](modes/git.md)
6565
- [Cross](modes/cross.md)
6666
- [Slide](modes/slides.md)
67-
- [Animation](modes/animations.md)
67+
- [Animation](modes/animations.md)
6868

6969
- [Examples](examples.md)
7070
- [Class hierarchy](examples/example1.md)
@@ -76,60 +76,60 @@
7676

7777
- [Bindings Reference](bindings_index.md)
7878
- [Why vim-like bindings](bindings/vim-like.md)
79-
- [Root level bindings](root_level_bindings.md)
79+
- [Root level bindings](root_level_bindings.md)
8080
- [GUI bindings](bindings/gui.md)
81-
- [Tab Management](bindings_group_tabs.md)
82-
- [Insert operations](insert_operation.md)
83-
- [box variants](bindings_group_insert_box.md)
84-
- [multiple elements](bindings_group_insert_multiple.md)
85-
- [unicode elements](bindings_group_insert_unicode.md)
86-
- [connected elements](bindings_group_insert_connected.md)
87-
- [lines](bindings_group_insert_line.md)
88-
- [stencils](bindings_group_insert_stencil.md)
89-
- [special elements](bindings_group_insert_element.md)
90-
- [rulers](bindings_group_insert_ruler.md)
91-
- [Element manipulation](element_operation.md)
81+
- [Tab Management](bindings_group_tabs.md)
82+
- [Insert operations](insert_operation.md)
83+
- [box variants](bindings_group_insert_box.md)
84+
- [multiple elements](bindings_group_insert_multiple.md)
85+
- [unicode elements](bindings_group_insert_unicode.md)
86+
- [connected elements](bindings_group_insert_connected.md)
87+
- [lines](bindings_group_insert_line.md)
88+
- [stencils](bindings_group_insert_stencil.md)
89+
- [special elements](bindings_group_insert_element.md)
90+
- [rulers](bindings_group_insert_ruler.md)
91+
- [Element manipulation](element_operation.md)
9292
- [Resizing elements](bindings/resizing.md)
93-
- [Grouping elements](element_grouping_operation.md)
94-
- [Spellchecking](spellchecking_operation.md)
95-
- [Arrow manipulation](arrow_operation.md)
96-
- [Arrow - Connectors](bindings_group_arrow_connectors.md)
97-
- [Start Connector](bindings_group_arrow_connectors_start.md)
98-
- [End Connector](bindings_group_arrow_connectors_end.md)
99-
- [Both Connectors](bindings_group_arrow_connectors_both.md)
100-
- [Fixed vs dynamic connectors](fixed_vs_dynamic_connectors.md)
101-
- [Yank](yank_operations.md)
102-
- [Mouse](mouse_operations.md)
103-
- [Image box](image_box_operations.md)
104-
- [Display option](visual_settings_operation.md)
105-
- [Color options](color_operations.md)
106-
- [Debug](debug_operations.md)
107-
- [Modes](modes_operation.md)
108-
- [Clone](clone_mode_operation.md)
109-
- [Eraser](eraser_mode.md)
110-
- [Pen](pen_mode.md)
111-
- [Arrow](arrow_mode.md)
112-
- [Find](find_mode.md)
113-
- [Git](git_mode.md)
114-
- [Selection](selection_mode_operation.md)
115-
- [Selection polygon mode](selection_polygon_mode.md)
116-
- [Slide](slide_mode.md)
117-
- [Animation](animation_mode.md)
118-
- [Animation script](animation_script_mode.md)
93+
- [Grouping elements](element_grouping_operation.md)
94+
- [Spellchecking](spellchecking_operation.md)
95+
- [Arrow manipulation](arrow_operation.md)
96+
- [Arrow - Connectors](bindings_group_arrow_connectors.md)
97+
- [Start Connector](bindings_group_arrow_connectors_start.md)
98+
- [End Connector](bindings_group_arrow_connectors_end.md)
99+
- [Both Connectors](bindings_group_arrow_connectors_both.md)
100+
- [Fixed vs dynamic connectors](fixed_vs_dynamic_connectors.md)
101+
- [Yank](yank_operations.md)
102+
- [Mouse](mouse_operations.md)
103+
- [Image box](image_box_operations.md)
104+
- [Display option](visual_settings_operation.md)
105+
- [Color options](color_operations.md)
106+
- [Debug](debug_operations.md)
107+
- [Modes](modes_operation.md)
108+
- [Clone](clone_mode_operation.md)
109+
- [Eraser](eraser_mode.md)
110+
- [Pen](pen_mode.md)
111+
- [Arrow](arrow_mode.md)
112+
- [Find](find_mode.md)
113+
- [Git](git_mode.md)
114+
- [Selection](selection_mode_operation.md)
115+
- [Selection polygon mode](selection_polygon_mode.md)
116+
- [Slide](slide_mode.md)
117+
- [Animation](animation_mode.md)
118+
- [Animation script](animation_script_mode.md)
119119

120120
# Configuration
121121

122122
- [Configuration](configuration.md)
123123
- [Configuration Format](config/config_format.md)
124-
- [Bindings Format](config/binding_format.md)
124+
- [Bindings Format](config/binding_format.md)
125125
- [Binding override](config/user_bindings/binding_override.md)
126126

127127
# Developer Guide
128128

129129
- [For Developers](for_developers/README.md)
130130
- [Scripting](for_developers/scripting.md)
131-
- [Execute](for_developers/scripting_execute.md)
132-
- [Simplified API](for_developers/scripting_api.md)
131+
- [Execute](for_developers/scripting_execute.md)
132+
- [Simplified API](for_developers/scripting_api.md)
133133
- [Modifying Asciio](for_developers/modify_Asciio.md)
134134
- [Bindings](for_developers/bindings.md)
135135
- [Capturing groups with overlay](config/user_bindings/capturing_groups_overlay.md)

documentation/mdbook_asciio/src/editing/mouse.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,13 @@ You can quickly create boxes and section by combining ***quick link*** and ***qu
6666

6767
![quick box and section](quick_box_and_section.gif)
6868

69+
## Mouse dragging canvas
70+
71+
If no element is selected, you can use the mouse to drag the canvas.
72+
73+
If at least one element is selected, other operations are performed. See [drag_drop](drag_drop.md).
74+
75+
***Binding:*** control + left click + drag
76+
77+
![mouse drag canvas](mouse_drag_canvas.gif)
78+
1.12 MB
Loading

lib/App/Asciio.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,10 @@ if($self->{PREVIOUS_X} != $x || $self->{PREVIOUS_Y} != $y)
825825

826826
$self->run_actions(["${modifiers}motion_notify", $event]) if $self->exists_action("${modifiers}motion_notify") ;
827827

828-
($self->{PREVIOUS_X}, $self->{PREVIOUS_Y}) = ($self->{MOUSE_X}, $self->{MOUSE_Y}) = ($x, $y) ;
828+
unless($self->{SKIP_COORDINATE_UPDATE})
829+
{
830+
($self->{PREVIOUS_X}, $self->{PREVIOUS_Y}) = ($self->{MOUSE_X}, $self->{MOUSE_Y}) = ($x, $y) ;
831+
}
829832
}
830833

831834
}

lib/App/Asciio/Actions/Mouse.pm

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use App::Asciio::Actions::ElementAttributes ;
66
#----------------------------------------------------------------------------------------------
77

88
use List::MoreUtils qw(any minmax first_value) ;
9+
use List::Util qw(max) ;
910
use Readonly ;
1011

1112
use App::Asciio::stripes::section_wirl_arrow ;
@@ -407,10 +408,19 @@ sub mouse_drag_canvas
407408
{
408409
my ($self, $event) = @_ ;
409410

411+
# If have elements are selected, DnD is executed.
412+
# If no element is selected, canvas drag is executed.
413+
return if $self->any_selected_elements() ;
414+
410415
my ($x, $y) = @{$event->{COORDINATES}}[0, 1] ;
411416

417+
($self->{PREVIOUS_X}, $self->{PREVIOUS_Y}) = ($x, $y) if ($event->{STATE} eq 'button1-press') ;
418+
412419
if($event->{STATE} eq 'dragging-button1' && ($self->{PREVIOUS_X} != $x || $self->{PREVIOUS_Y} != $y))
413420
{
421+
# The coordinates cannot be updated during the dragging process, otherwise
422+
# the source and target coordinates will be incorrect.
423+
$self->{SKIP_COORDINATE_UPDATE} = 1 ;
414424
my ($character_width, $character_height) = $self->get_character_size() ;
415425

416426
my $h_value = $self->{hadjustment}->get_value() ;
@@ -419,29 +429,14 @@ if($event->{STATE} eq 'dragging-button1' && ($self->{PREVIOUS_X} != $x || $self-
419429
my $new_h_value = $h_value - (($x - $self->{PREVIOUS_X}) * $character_width) ;
420430
my $new_v_value = $v_value - (($y - $self->{PREVIOUS_Y}) * $character_height) ;
421431

422-
if($new_h_value >= 0)
423-
{
424-
$self->{hadjustment}->set_value($new_h_value) ;
425-
}
426-
else
427-
{
428-
# scrollbar reached top
429-
}
430-
431-
if($new_v_value >= 0)
432-
{
433-
$self->{vadjustment}->set_value($new_v_value) ;
434-
}
435-
else
436-
{
437-
# scrollbar reached top
438-
}
439-
}
440-
else
441-
{
442-
($self->{PREVIOUS_X}, $self->{PREVIOUS_Y}) = ($self->{MOUSE_X}, $self->{MOUSE_Y}) ;
443-
($self->{MOUSE_X}, $self->{MOUSE_Y}) = ($x, $y) ;
432+
# when <=0 scrollbar reached top
433+
$self->{hadjustment}->set_value(max($new_h_value, 0)) ;
434+
$self->{vadjustment}->set_value(max($new_v_value, 0)) ;
435+
return ;
444436
}
437+
438+
delete $self->{SKIP_COORDINATE_UPDATE} ;
439+
($self->{PREVIOUS_X}, $self->{PREVIOUS_Y}) = ($self->{MOUSE_X}, $self->{MOUSE_Y}) = ($x, $y) ;
445440
}
446441

447442
#----------------------------------------------------------------------------------------------

setup/actions/default_bindings.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129

130130
'Mouse motion' => ['000-motion_notify', \&App::Asciio::Actions::Mouse::mouse_motion, undef, { HIDE => 1} ],
131131
'Mouse motion 2' => ['0AS-motion_notify', \&App::Asciio::Actions::Mouse::mouse_motion, undef, { HIDE => 1} ],
132+
'Mouse drag canvas' => ['C00-motion_notify', \&App::Asciio::Actions::Mouse::mouse_drag_canvas ],
132133

133134
# mouse emulation
134135
'Mouse emulation toggle' => [['000-apostrophe', "'"], \&App::Asciio::Actions::Mouse::toggle_mouse ],

0 commit comments

Comments
 (0)