Post

Collection of S60 UI tricks

I’m currently busy with the next AntSnes release. Here is some S60 UI ticks I used in the previous AntSnes v0.3 release.
Starting a menupane at app startup.

1
2
//at AppUI ConstructL
CEikonEnv::Static()->AppUiFactory()->MenuBar()->TryDisplayMenuBarL();

Keeping the backlight on.

1
2
//call this often enough. For example once in each second
User::ResetInactivityTime(); //keep the backlight on

Catching events when menubar is opened, or cancelled/closed, so we can stop and start the emulation again.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//See when menu was launched in here
void CAntSnesAppUi::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
{
    if( aResourceId == R_MENU ) //if R_MENU, then the menupane was launched
    {
        PauseEmulation();
        iMenuOpen = ETrue;
    }
}

// Handle key events, see if it was a cancel event and menubar flag was on
// ESCAPE cancels loading or saving
TKeyResponse CAntSnesAppUi::HandleKeyEventL(const TKeyEvent aKeyEvent,TEventCode aType)
{
    if( aKeyEvent.iScanCode == EStdKeyDevice1 and iMenuOpen )
    {
        //The menu is cancelled, continue emulation
        continueEmulation();
        iMenuOpen = EFalse;
    }
    return EKeyWasNotConsumed;
}
//The some command was chosen from menubar, disable flag, and continiue emulation
void CAntSnesAppUi::HandleCommandL(TInt aCommand)
{
    iMenuOpen = EFalse;
    continueEmulation();
}
This post is licensed under CC BY 4.0 by the author.