![]()
![]()
![]()
MUIM_HandleInput ================ Compared with BOOPSI, MUI uses a different input handling scheme. Not only the "active" object but instead all objects may receive input events at the same time. Since sending input events to every object in a window would be an incredible overhead, you have to specify what messages you really need. MUI offers the library calls MUI_RequestIDCMP() and MUI_RejectIDCMP() for this purpose. Whenever an arriving input event matches your request, your object will receive a MUIM_HandleInput method. You can call MUI_RequestIDCMP() and MUI_RejectIDCMP() at every time. Performance affecting critical events like INTUITICKS and MOUSEMOVEs should only be requested when you really need them. The "Class3" for example requests MOUSEBUTTONS and RAWKEY during MUIM_Setup. The critical MOUSEMOVES are only requested when a button was pressed and immediately rejected after it was released again. Beneath the struct IntuiMessage, MUIM_HandleInput receives a longword describing a MUIKEY as second parameter. If this is set to some other value as MUIKEY_NONE, your object is the actve object and the input event translated to a user configured keyboard action. MUI will *not* translate input events to your objects coordinates. This is up to you. A typical input implementation could look like this: static ULONG mHandleInput( struct IClass *cl, Object *obj, struct MUIP_HandleInput *msg) { #define _between(a,x,b) ((x)>=(a) && (x)<=(b)) #define _isinobject(x,y) (_between(_mleft(obj),(x),_mright (obj))\ && _between(_mtop(obj) ,(y),_mbottom(obj))) struct Data *data = INST_DATA(cl,obj); if (msg->muikey) { switch (msg->muikey) { case MUIKEY_LEFT : data->sx=-1; MUI_Redraw(obj,MADF_DRAWUPDATE); break; case MUIKEY_RIGHT: data->sx= 1; MUI_Redraw(obj,MADF_DRAWUPDATE); break; case MUIKEY_UP : data->sy=-1; MUI_Redraw(obj,MADF_DRAWUPDATE); break; case MUIKEY_DOWN : data->sy= 1; MUI_Redraw(obj,MADF_DRAWUPDATE); break; } } if (msg->imsg) { switch (msg->imsg->Class) { case IDCMP_MOUSEBUTTONS: { if (msg->imsg->Code==SELECTDOWN) { if (_isinobject(msg->imsg->MouseX,msg->imsg->MouseY)) { data->x = msg->imsg->MouseX; data->y = msg->imsg->MouseY; MUI_Redraw(obj,MADF_DRAWUPDATE); MUI_RequestIDCMP(obj,IDCMP_MOUSEMOVE); } } else MUI_RejectIDCMP(obj,IDCMP_MOUSEMOVE); } break; case IDCMP_MOUSEMOVE: { if (_isinobject(msg->imsg->MouseX,msg->imsg->MouseY)) { data->x = msg->imsg->MouseX; data->y = msg->imsg->MouseY; MUI_Redraw(obj,MADF_DRAWUPDATE); } } break; } } /* passing MUIM_HandleInput to the super class is only necessary if you rely on area class input handling (MUIA_InputMode). */ return(0); }