Hi Laurent,

I'm excited about all the enhancements you are making to Win32::GUI these days, can hardly wait to try them out!


On approximately 3/28/2004 11:56 AM, came the following characters from
the keyboard of Laurent ROCHER:

Hi,

Some small bug fix :
    - UpDown :
        + Fix Scroll event.
    - GUI_Events.cpp :
        + In DoEvent_* functions : PERLWIN32GUI_EVENTHANDLING is set after
event call.

I looking for NEM support for accelerator and i don't know if my current
implementation was good.

Of course a strong correlation to the behavior in OEM would be best, at least as a default behavior. Other options could be considered, but they should be options, not the default.

If you look in sample below, you see it's always call -onClick window event
with accelerator name but not call button click event like in OEM.
For NEM support it's probably nicer to call Button click method like OEM do.
What do you think ?

I would agree calling the button click event would be better.... if the button click event exists.

So Accellerator table is made of

   "key" => "name"

where _Click event should be called for the widget named "name". That assumes that

1) A widget named "name" is defined
2) The widget supports a _Click event  (in OEM, sub name_Click exists)

In OEM, I think if either of the above is false, that the accelerator has no useful effect.

In NEM, the default behavior should be similiar: if the widget named "name" exists, and has a sub defined for _Click event, it should be called.

But we could also define additional behaviors for accelerators...

A) Calling the _Click event of the parent Window, as you seem to be presently doing, might be a nice default if there is no widget named "name", or it has on _Click event.

B) Maybe instead of overusing the _Click event of the parent Window, one could define a new parent -onAccel event, that would get called with the
accelerator name as a parameter, if there is no widget named "name".

I think if there is a widget named "name", and it doesn't have a _Click event, then the accelerator for that name should be ignored until there is a _Click event defined for that widget.

This would result in an extension to the current Accelerator support, allowing definition of Accelerators that don't have corresponding GUI actions. Which I think is not only OK, but could be very useful. One could put the essence of the interface on the GUI, but one could define Accelerator keys that could do complex combinations of GUI actions, or even non-GUI actions, instead of being limited to the unit actions available on the GUI.

C) One could change AcceleratorTable from

   "key" => "name"

to also allow

   "key" => sub { },

and this would get the parent window and the accelerator key as parameters? And would completely decouple that accelerator key from any named widget. Clearly this would be more work to implement, but would nicely fit the NEM model, as far as I can tell.

Laurent.

use Win32::GUI;

my $acc = new Win32::GUI::AcceleratorTable(
 "A" => "Window",
 "B" => "Button",
);

$W = new Win32::GUI::Window(
    -name   => "Window",
    -title  => "test",
    -pos    => [100, 100],
    -size   => [280, 280],
    -accel  => $acc,
    # NEM call comment for OEM.
    -onClick => sub { my ($self, $name) = @_; print "Window OnClick :
$name\n"; },
);

$W->AddButton(
    -name    => "Button",
    -pos     => [5,  5],
    -size    => [100, 100],
    -text    => "Just button",
);

$W->Show;
Win32::GUI::Dialog();

# OEM call
sub Window_Click {
  print "Window_Click\n";
}

sub Button_Click {
  print "Button_Click\n";
}



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Perl-Win32-GUI-Hackers mailing list
Perl-Win32-GUI-Hackers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-hackers



--
Glenn -- http://nevcal.com/
===========================
The best part about procrastination is that you are never bored,
because you have all kinds of things that you should be doing.


Reply via email to