ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Macro.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Macro.pm (file contents):
Revision 1.1 by root, Sat Dec 9 02:21:25 2006 UTC vs.
Revision 1.3 by root, Sat Dec 9 22:06:51 2006 UTC

154 $window->connect (key_up => $key_cb); 154 $window->connect (key_up => $key_cb);
155 $window->connect (key_down => $key_cb); 155 $window->connect (key_down => $key_cb);
156 156
157 $window->grab_focus; 157 $window->grab_focus;
158 $window->show; 158 $window->show;
159}
160
161# find macro by event
162# maybe return multiple results?
163sub match_event($) {
164 my ($ev) = @_;
165
166 for my $macro (@{ $::PROFILE->{macro} || [] }) {
167 my $key = $macro->{accelkey}
168 or next;
169
170 $key->[1] == $ev->{sym}
171 && $key->[0] == ($ev->{mod} & $MODIFIER_MASK)
172 && return $macro;
173 }
174
175 ()
159} 176}
160 177
161sub keyboard_setup { 178sub keyboard_setup {
162 my $kbd_setup = new CFPlus::UI::VBox; 179 my $kbd_setup = new CFPlus::UI::VBox;
163 180
321 can_events => 1, 338 can_events => 1,
322 on_button_down => $macro_cb, 339 on_button_down => $macro_cb,
323 ); 340 );
324 341
325 $macros->add (1, $y, new CFPlus::UI::Label 342 $macros->add (1, $y, new CFPlus::UI::Label
326 text => (join "; ", @{ $macro->{action} }), 343 text => (join "; ", @{ $macro->{action} || [] }),
327 tooltip => $tooltip_commands . $tooltip_common, 344 tooltip => $tooltip_commands . $tooltip_common,
328 expand => 1, 345 expand => 1,
329 ellipsise => 3, 346 ellipsise => 3,
330 can_hover => 1, 347 can_hover => 1,
331 can_events => 1, 348 can_events => 1,
340} 357}
341 358
342# this is a shortcut method that asks for a binding 359# this is a shortcut method that asks for a binding
343# and then just binds it. 360# and then just binds it.
344sub quick_macro { 361sub quick_macro {
345 my ($self, $cmds, $end_cb) = @_; 362 my ($cmds, $end_cb) = @_;
346 363
347 my $macro = { 364 my $macro = {
348 action => $cmds, 365 action => $cmds,
349 }; 366 };
350 367
351 trigger_edit $macro, sub { 368 trigger_edit $macro, sub {
352
353 if ($_[0]) { 369 if ($_[0]) {
354 push @{ $::PROFILE->{macro} }, $macro; 370 push @{ $::PROFILE->{macro} }, $macro;
355 $REFRESH_MACRO_LIST->(); 371 $REFRESH_MACRO_LIST->();
356 } 372 }
357 373

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines