--- deliantra/Deliantra-Client/DC/Macro.pm 2006/12/09 02:21:25 1.1 +++ deliantra/Deliantra-Client/DC/Macro.pm 2006/12/09 22:06:51 1.3 @@ -158,6 +158,23 @@ $window->show; } +# find macro by event +# maybe return multiple results? +sub match_event($) { + my ($ev) = @_; + + for my $macro (@{ $::PROFILE->{macro} || [] }) { + my $key = $macro->{accelkey} + or next; + + $key->[1] == $ev->{sym} + && $key->[0] == ($ev->{mod} & $MODIFIER_MASK) + && return $macro; + } + + () +} + sub keyboard_setup { my $kbd_setup = new CFPlus::UI::VBox; @@ -323,7 +340,7 @@ ); $macros->add (1, $y, new CFPlus::UI::Label - text => (join "; ", @{ $macro->{action} }), + text => (join "; ", @{ $macro->{action} || [] }), tooltip => $tooltip_commands . $tooltip_common, expand => 1, ellipsise => 3, @@ -342,14 +359,13 @@ # this is a shortcut method that asks for a binding # and then just binds it. sub quick_macro { - my ($self, $cmds, $end_cb) = @_; + my ($cmds, $end_cb) = @_; my $macro = { action => $cmds, }; trigger_edit $macro, sub { - if ($_[0]) { push @{ $::PROFILE->{macro} }, $macro; $REFRESH_MACRO_LIST->();