RE: Accelerator Keys not working . . .

new topic     » goto parent     » topic index » view thread      » older message » newer message

> -----Original Message-----
> From: jjnick at cvn.com [mailto:jjnick at cvn.com]
> Sent: Friday, 25 May 2001 3:32 PM
> To: EUforum
> Subject: Re: Accelerator Keys not working . . .
>
> > procedure clicks(integer self, integer event, sequence parms)
> >     setText(sb, sprintf("Button = '%s' (%d)",
> {getText(self), self}))
> > end procedure
> >
> > setHandler({btn1,btn2,btn3}, w32HClick, routine_id("clicks"))
> >
>
> So, for every button I have an accelerator for, I have to
> call a unique
> procedure which then calls the appropriate "onClick" procedure?
>

No. This is just ONE way you can do it. Here is another....

  procedure OrderPizza(integer self, integer event, sequence parms)
   -- The user wants to order a pizza.
    . . .
  end procedure
  setHandler(btn1, w32HClick, routine_id("OrderPizza"))

  procedure TurnLeft(integer self, integer event, sequence parms)
    -- Quick! Turn left now!
    . . .
  end procedure
  setHandler(btn2, w32HClick, routine_id("TurnLeft"))

  procedure WalkTheDog(integer self, integer event, sequence parms)
    -- The wife wants you to mow the lawns.
    . . .
  end procedure
  setHandler(btn3, w32HClick, routine_id("WalkTheDog"))

My example was just a shorthand way of doing ...

  setHandler(btn1, w32HClick, routine_id("clicks"))
  setHandler(btn2, w32HClick, routine_id("clicks"))
  setHandler(btn3, w32HClick, routine_id("clicks"))

because I wanted all three buttons to invoke the same routine.
Alternatively, I could have coded three routines, given them all different
names but coded them to do the same thing.

Note, when using the "setHandler" method of telling Win32lib what to do for
an event, the procedure you code must ALWAYS take three parameters;
  integer self   --  the ID of the control that invoked the handler,
  integer event  --  the Win32lib name for the event, eg. "w32HClick",
  sequence parms --  a list of data that comes with the event. This
                     varies with the type of event. See the docs for
                     details.

The use of setHandler(), instead of onXXX[], allows for changes to the
internals of Win32lib without breaking existing code, allows app writers to
create "generic" handlers if required, makes it easier for IDE writers to
generate apps using Win32lib, makes it possible for developers to create new
control types with their own event types, and they are invoked (slightly)
faster.

But that's just my opinion.

----------
cheers,
Derek Parnell
Senior Design Engineer
Global Technology Australasia Ltd
dparnell at glotec.com.au

---------------------

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu