Toolbox event habdling
Tony van der Hoff
OSLib at mk-net.demon.co.uk
Wed Oct 11 14:49:42 BST 2000
I've been looking at our support for handling of toolbox events, and
unless I've completely got my wires crossed (in which case someone will
tell me - my reason for posting ;-), I think it can be improved upon.
Firstly, Toolbox events are a specialised form of Wimp events. The poll
block consists of a standard header, followed by event-specific data.
Currently, OSLib defines the format of this block as:
TYPE
Toolbox_Action = .Struct
( .Int: size,
.Int: ref_no,
.Bits: action_no,
.Bits: flags,
.Union
( Toolbox_ActionError: error,
Toolbox_ActionObjectAutoCreated: created,
Toolbox_ActionObjectDeleted: deleted,
[212] .Byte: reserved
): data
);
All object-specific events are defined as only the data part, as in:
TYPE
Menu_ActionAboutToBeShown = .Struct
( Toolbox_PositionTag: tag,
.Union
( OS_Coord: top_left,
Menu_Full: full
): position
);
So, all event handlers have to receive a Toolbox_Action structure, and
then extract the event-specific data using a clumsy cast.
I propose to define:
TYPE
Toolbox_ActionHeader = .Struct
(
.Int: size,
.Int: ref_no,
.Bits: action_no,
.Bits: flags
);
which would then allow me to define (for instance):
TYPE
Menu_ActionAboutToBeShownBlock = .Struct
(
Toolbox_ActionHeader: hdr,
Toolbox_PositionTag: tag,
.Union
( OS_Coord: top_left,
Menu_Full: full
): position
);
which then can be directly used by a MenuAboutToBeShown event handler.
This would have to be done for all possible toolbox events, so a fair
amount of work, but other than that, can anyone see any flaws in this
proposal? Of course, for more general-purpose event handlers, the
existing system would still be appropriate.
Alternatively, would it be more sensible to try to "generalise" the
event structure like we did for wimp message structures?
Secondly, OSLib defines:
TYPE
Iconbar_ActionAboutToBeShown = .Struct
( Toolbox_PositionTag: tag,
.Union
( OS_Coord: top_left,
Iconbar_Full: full
): position
);
Looking at the documentation, I believe this is wrong, and should be:
TYPE
Iconbar_ActionAboutToBeShown = .Struct
( Toolbox_O: o
);
If so, it just goes to show that no-one is using the present structure.
Any comments?
--
Tony van der Hoff | mailto:OSLib at mk-net.demon.co.uk
Buckinghamshire, England | http://www.mk-net.demon.co.uk/oslib/
----------------------------------------------------------------
More information about the oslib-user
mailing list