Monday, August 20, 2007

Overriding the silk screen buttons

In the main event loop, scan for the keyDown event before SysHandleEventgets to process it. If the character is vchrFind, you skip the rest of the event loop, effectively ignoring the find button.
For example:

static void EventLoop()
{ Err error; EventType event;
do

{
EvtGetEvent(&event, evtWaitForever);
// Eat all find key events

if (event.eType == keyDownEvent && event.data.keyDown.chr == vchrFind)
{
continue;
}
if (!SysHandleEvent(&event))

{
if (!MenuHandleEvent(0, &event, &error))
{
if (!ApplicationHandleEvent(&event))
{
FrmDispatchEvent(&event);
}
}
}
}while (event.eType != appStopEvent);
}

/***************************************OR*****************************************************/

PenBtnInfoPtr btnInfo;
UInt16 numButtons;

btnInfo = (const PenBtnInfoPtr)EvtGetPenBtnList(&numButtons); //Get the list of silk screen buttons.

for(int i =0; i
{
if((pEvent->data.keyDown.chr)==btnInfo[i].asciiCode)
{
FrmCustomAlert(GenericErrorAlert,"Silk Screen button selected","","");
return true;
}
}

No comments: