try to offload exception handling
[AROS.git] / compiler / alib / hotkey.c
blobd1d8416cadcb933ddbd6f5ca7428b3e9f2372da6
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /*****************************************************************************
8 NAME */
10 #include <proto/exec.h>
11 #include <proto/commodities.h>
12 #include <libraries/commodities.h>
14 extern struct Library *CxBase;
16 CxObj *HotKey(
18 /* SYNOPSIS */
19 STRPTR description,
20 struct MsgPort *port,
21 LONG id
24 /* FUNCTION
25 A simple way to get a hotkey for your program. The program is
26 posted a message when the user does the specified input action in
27 'description' regardless of whether the program has input focus or
28 not. The key combination event is swallowed, that is not sent any
29 farther in the input system.
31 It's recommended that the user should be able to specify a
32 program's hotkey with tooltypes, for instance
33 HOTKEY="alt shift f5".
35 INPUTS
36 description -- commodities filter description (see
37 commodities.library/SetFilter())
38 port -- message port the hotkey messages will be sent to
39 id -- identifier (see CxSender())
41 RESULT
42 A pointer to a filter object which represents the HotKey.
44 NOTES
45 Commodities.library must be open at the time of the call.
47 EXAMPLE
49 BUGS
51 SEE ALSO
52 commodities.library/CxFilter(), commodities.library/CxTranslate(),
53 commodities.library/CxSender(), commodities.library/SetFilter(),
54 commodities.library/CxObjError()
56 INTERNALS
58 HISTORY
60 26.04.98 SDuvan implemented
62 *****************************************************************************/
64 CxObj *filter; /* The objects making up the hotkey */
65 CxObj *sender; /* functionality... */
66 CxObj *translator;
68 if((filter = CxFilter(description)) == NULL)
69 return NULL;
71 if((sender = CxSender(port, id)) == NULL)
73 DeleteCxObj(filter);
74 return NULL;
77 AttachCxObj(filter, sender);
79 /* Create the commodities equivalent of NIL: */
80 if((translator = CxTranslate(NULL)) == NULL)
82 DeleteCxObjAll(filter);
83 return NULL;
86 AttachCxObj(filter, translator);
88 return filter;
90 } /* HotKey */