SophiaFramework UNIVERSE 5.3 |
For a responder to receive and handle an event, make a handler using the handler macro below.
There are 2 types of handlers from the purpose point of view:
Each handler has its own handler macro to make itself.
There are 2 types of handlers from the return value point of view:
Reference: Handler | SFXEvent | SFXEventRange | SFCEventEnum
Example 9.205. Handler declaration
XANDLER_DECLARE_VOIDVOID(FUNCTION)
// or
XANDLER_DECLARE_BOOLVOID(FUNCTION)
Table 9.80. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Function name for the handler. |
Example 9.207. Handler declaration
XANDLER_DECLARE_VOIDEVENT(FUNCTION)
// or
XANDLER_DECLARE_BOOLEVENT(FUNCTION)
Table 9.82. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.208. Handler implementation
XANDLER_IMPLEMENT_VOIDEVENT(CLASS, FUNCTION, invoker, event)
{
return;
}
// or
XANDLER_IMPLEMENT_BOOLEVENT(CLASS, FUNCTION, invoker, event)
{
return false;
}
Table 9.83. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the SFXEventConstRef type. | Event. |
Reference: Key Event[from SFEVT_KEY to SFEVT_KEY_HOOK_RELEASE] | Control Event[from SFEVT_COMMAND to SFEVT_CTL_TEXT_MODECHANGED] | Dialog Event[from SFEVT_DIALOG_INIT to SFEVT_COPYRIGHT_END] | Shell Event[from SFEVT_ALARM to SFEVT_NOTIFY_FAILURE] | Device Event[from SFEVT_FLIP to SFEVT_SCR_ROTATE] | Clipboard Event[from SFEVT_CB_CUT to SFEVT_CB_PASTE] | Other Applet Event[from SFEVT_APP_CONFIG to SFEVT_APP_START_WINDOW] | SoftKey Event[SFEVT_RESPONDER_SOFTKEY]
Example 9.209. Handler declaration
XANDLER_DECLARE_VOIDSTART(FUNCTION)
// or
XANDLER_DECLARE_BOOLSTART(FUNCTION)
Table 9.84. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.210. Handler implementation
XANDLER_IMPLEMENT_VOIDSTART(CLASS, FUNCTION, invoker, environment)
{
return;
}
// or
XANDLER_IMPLEMENT_BOOLSTART(CLASS, FUNCTION, invoker, environment)
{
return false;
}
Table 9.85. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the AEEAppStart* type | Information on booting up. |
Reference: Applet-Bootup Event[SFEVT_APP_START] | AEEAppStart | BREW API AEEEvent
Example 9.211. Handler declaration
XANDLER_DECLARE_VOIDSTOP(FUNCTION)
// or
XANDLER_DECLARE_BOOLSTOP(FUNCTION)
Table 9.86. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.212. Handler implementation
XANDLER_IMPLEMENT_VOIDSTOP(CLASS, FUNCTION, invoker, quitable)
{
return;
}
// or
XANDLER_IMPLEMENT_BOOLSTOP(CLASS, FUNCTION, invoker, quitable)
{
return false;
}
Table 9.87. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the BoolPtr type | Confirmation for termination. |
Reference: Applet-Terminate Event[SFEVT_APP_STOP]
Example 9.213. Handler declaration
XANDLER_DECLARE_VOIDRESUME(FUNCTION)
// or
XANDLER_DECLARE_BOOLRESUME(FUNCTION)
Table 9.88. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.214. Handler implementation
XANDLER_IMPLEMENT_VOIDRESUME(CLASS, FUNCTION, invoker, environment)
{
return;
}
// or
XANDLER_IMPLEMENT_BOOLRESUME(CLASS, FUNCTION, invoker, environment)
{
return false;
}
Table 9.89. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the AEEAppStart* type | Information on resuming. |
Reference: Applet-Resume Event[SFEVT_APP_RESUME] | AEEAppStart | BREW API AEEEvent
Example 9.215. Handler declaration
XANDLER_DECLARE_VOIDSUSPEND(FUNCTION)
// or
XANDLER_DECLARE_BOOLSUSPEND(FUNCTION)
Table 9.90. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.216. Handler implementation
XANDLER_IMPLEMENT_VOIDSUSPEND(CLASS, FUNCTION, invoker, reason, info)
{
return;
}
// or
XANDLER_IMPLEMENT_BOOLSUSPEND(CLASS, FUNCTION, invoker, reason, info)
{
return false;
}
Table 9.91. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the AEESuspendReason type | Reason for suspending. |
5 | Variable name of the AEESuspendInfo* type | Information on suspending. |
Reference: Applet-Suspend Event[SFEVT_APP_SUSPEND]
Table 9.92. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.218. Handler implementation
XANDLER_IMPLEMENT_VOIDOWNER(CLASS, FUNCTION, invoker, reason, responder) { return; }
Table 9.93. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the UInt16 type | P16 parameter of the event. |
5 | Variable name of the SFYResponderPtr type | Notified responder. |
Reference: Parent Child Event[SFEVT_RESPONDER_OWNER]
Table 9.94. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.220. Handler implementation
XANDLER_IMPLEMENT_VOIDFRAME(CLASS, FUNCTION, invoker, reason, responder) { return; }
Table 9.95. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the UInt16 type | P16 parameter of the event. |
5 | Variable name of the SFYResponderPtr type | Notified responder. |
Reference: Parent Child Event[SFEVT_RESPONDER_FRAME]
Table 9.96. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.222. Handler implementation
XANDLER_IMPLEMENT_VOIDBOUND(CLASS, FUNCTION, invoker, reason, rectangle) { return; }
Table 9.97. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the UInt16 type | P16 parameter of the event. |
5 | Variable name of the SFXRectanglePtr type | Notified rectangle. |
Reference: Region Event[SFEVT_RESPONDER_BOUND]
Table 9.98. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.224. Handler implementation
XANDLER_IMPLEMENT_VOIDMARGIN(CLASS, FUNCTION, invoker, reason, margin) { return; }
Table 9.99. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the UInt16 type | P16 parameter of the event. |
5 | Variable name of the SFXMarginPtr type | Notified margin. |
Reference: Margin Event[SFEVT_RESPONDER_MARGIN]
Table 9.100. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.226. Handler implementation
XANDLER_IMPLEMENT_VOIDSTATE(CLASS, FUNCTION, invoker, reason, state) { return; }
Table 9.101. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the UInt16 type | P16 parameter of the event. |
5 | Variable name of the Bool type | Notified state. |
Reference: State Event[SFEVT_RESPONDER_STATE]
Table 9.102. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.228. Handler implementation
XANDLER_IMPLEMENT_VOIDFOCUS(CLASS, FUNCTION, invoker, reason, focus) { return; }
Table 9.103. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the UInt16 type | P16 parameter of the event. |
5 | Variable name of the Bool type | Focus state. |
Reference: Focus Event[SFEVT_RESPONDER_FOCUS]
Table 9.104. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.230. Handler implementation
XANDLER_IMPLEMENT_VOIDRENDER(CLASS, FUNCTION, invoker, reason, graphics) { return; }
Table 9.105. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the UInt16 type | P16 parameter of the event. |
5 | Variable name of the SFXGraphicsPtr type | Graphics object. |
Reference: Drawing Event[SFEVT_RESPONDER_RENDER]
Table 9.106. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.232. Handler implementation
XANDLER_IMPLEMENT_VOIDSTYLE(CLASS, FUNCTION, invoker, reason) { return; }
Table 9.107. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the UInt16 type | P16 parameter of the event. |
Reference: Style Event[SFEVT_RESPONDER_STYLE]
Table 9.108. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.234. Handler implementation
XANDLER_IMPLEMENT_VOIDVALUE(CLASS, FUNCTION, invoker, reason, value) { return; }
Table 9.109. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the UInt16 type | P16 parameter of the event. |
5 | Variable name of the SInt32 type | Notified value. |
Reference: Value Event[SFEVT_RESPONDER_VALUE]
Table 9.110. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.236. Handler implementation
XANDLER_IMPLEMENT_VOIDRESULT(CLASS, FUNCTION, invoker, reason, result) { return; }
Table 9.111. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the UInt16 type | P16 parameter of the event. |
5 | Variable name of the SInt32 type | Notified result. |
Reference: Result Event[SFEVT_RESPONDER_RESULT]
Table 9.112. Declaration macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Name of the handler function. |
Example 9.238. Handler implementation
XANDLER_IMPLEMENT_VOIDSCROLLBAR(CLASS, FUNCTION, invoker, reason) { return; }
Table 9.113. Implementation macro argument
Number | Content | Description |
---|---|---|
1 | Class name | The handler is registered into this calss. |
2 | Function name | Name of the handler function. |
3 | Variable name of the SFYResponderPtr type | Responder which will boot up the handler. |
4 | Variable name of the UInt16 type | P16 parameter of the event. |
Reference: Scroll Bar Event[SFEVT_RESPONDER_SCROLLBAR]
XANDLER_FUNCTION is a macro to get the entry name for the specified handler.
Example 9.239. Definition of the XANDLER_FUNCTION Macro
#define XANDLER_FUNCTION(FUNCTION) FUNCTION##SHP
Table 9.114. Macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Function name to get the entry name of a handler. |
How to use the XANDLER_FUNCTION macro | |
---|---|
This macro is used to register more than one handler together at the same time. |
static SFXEventRange::AtomRecConst range[] = { { SFEVT_KEY, SFEVT_KEY, SFP16_BEGIN, SFP16_END}, { SFEVT_KEY_PRESS, SFEVT_KEY_PRESS, SFP16_BEGIN, SFP16_END}, { SFEVT_KEY_RELEASE, SFEVT_KEY_RELEASE, SFP16_BEGIN, SFP16_END} }; SFYHandler::RuleRec rule[lengthof(range)]; SFCError error; rule[0].spp = XANDLER_FUNCTION(OnKey); rule[0].reference = this; rule[1].spp = XANDLER_FUNCTION(OnKeyPress); rule[1].reference = this; rule[2].spp = XANDLER_FUNCTION(OnKeyRelease); rule[2].reference = this; error = RegisterHandler(atomic_cast(range), rule, lengthof(range));
XANDLER_INTERNAL is a macro to get the handler referring to the "this" instance.
This macro is used to register a handler into a responder with the arguments of the pointer to the handler function and the reference to the "this" instance.
Example 9.240. Definition of the XANDLER_INTERNAL Macro
#define XANDLER_INTERNAL(FUNCTION) (XANDLER_FUNCTION(FUNCTION)), (this)
Table 9.115. Macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Function name to get the handler. |
SFCError error; error = RegisterHandler(SFXEventRange(SFEVT_KEY, SFEVT_KEY, SFP16_BEGIN, SFP16_END), XANDLER_INTERNAL(OnKey));
XANDLER_EXTERNAL is a macro to get the handler referring to the instance specified in the argument.
This macro is used to register a handler into a responder with the arguments of the pointer to the handler function and the reference to the specified instance.
Example 9.241. Definition of the XANDLER_EXTERNAL Macro
#define XANDLER_EXTERNAL(FUNCTION, REFERENCE) (XANDLER_FUNCTION(FUNCTION)), ((REFERENCE))
Table 9.116. Macro argument
Number | Content | Description |
---|---|---|
1 | Function name | Function name to get the handler. |
2 | Variable name of the instance | Variable name which will contain the external instance. |
XANDLER_INTERNAL macro and XANDLER_EXTERNAL macro | |
---|---|
The XANDLER_INTERNAL macro is used to get the handler referring to the "this" instance. With this macro, the handler is automatically expanded into the sentence structure including the "this" variable. The XANDLER_EXTERNAL macro is used to get the handler referring to the specified instance. With this macro, the handler is automatically expanded into the sentence structure including the specified instance in the argument. Since the handler refers to the "this" instance in almost all cases, usually the XANDLER_INTERNAL macro is used. The "this" variable is not available in the static function. The instance to pass may not be the "this" variable but the external responder. The XANDLER_EXTERNAL macro is used in these cases. |
XANDLER_NULL is a macro to get the null handler.
In case the null handler is registered, though the null handler is not booted up actually, it is assumed to have handled an event.
For instance, the code to handle and invalidate(do nothing) all key events is as follows:
SFCError error; error = RegisterHandler(SFXEventRange(SFEVT_KEY, SFEVT_KEY, SFP16_BEGIN, SFP16_END), XANDLER_NULL);
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |