本文整理汇总了C++中TWsEvent::Key方法的典型用法代码示例。如果您正苦于以下问题:C++ TWsEvent::Key方法的具体用法?C++ TWsEvent::Key怎么用?C++ TWsEvent::Key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TWsEvent
的用法示例。
在下文中一共展示了TWsEvent::Key方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CloseDialogsL
/**
Utility to close the dialogs once the screen has been compared
with a previous capture of an expected display.
*/
void CConeErrorMsgTestAppUi::CloseDialogsL()
{
User::LeaveIfError(iWs.Connect());
TInt wgFocus = iWs.GetFocusWindowGroup();
const TUint32 ENullWsHandle = 0xFFFFFFFF; // Events delivered to this handle are thrown away
RWindowGroup wg = RWindowGroup(iWs);
wg.Construct(ENullWsHandle);
TInt wgId = wg.Identifier();
TWsEvent event;
event.SetType(EEventKey);
TKeyEvent *keyEvent = event.Key();
keyEvent->iCode = EKeyEscape;
keyEvent->iScanCode = EStdKeyEscape;
keyEvent->iModifiers = 0;
TInt limit = 0;
for(limit = 0; wgFocus != wgId && (limit < 50); limit++)
{
iWs.SendEventToAllWindowGroups(event);
wgFocus = iWs.GetFocusWindowGroup();
RDebug::Print(_L("CloseAllPanicWindowsL() - EKeyEscape sent to Windows Group"));
}
wg.Close();
iWs.Close();
}
示例2: GetWgEvent
void CButton::GetWgEvent()
{
#ifdef __DEBUG
__LOGSTR1("GetWgEvent,iStatus: %d",iStatus.Int());
#endif
if(iStatus == KErrNone)
{
TWsEvent e;
iWs.GetEvent(e);
#ifdef __DEBUG
__LOGSTR1("event: %d",e.Type());
#endif
switch(e.Type())
{
case EEventPointer:
case EEventPointerEnter:
case EEventDragDrop:
{
__LOGSTR("SendClose");
iMconnect->SendClose();
break;
}
case EEventFocusGained:
__LOGSTR("Focus gained");
iIsFocus = ETrue;
//iColor = KRgbGreen;
break;
case EEventFocusLost:
__LOGSTR("Focus lost");
iIsFocus = EFalse;
//iColor = KRgbRed;
break;
case EEventKeyDown:
__LOGSTR2("EEventKeyDown,iIsFocus: %d,iScanCode: %d",iIsFocus,e.Key()->iScanCode);
if(iIsFocus && e.Key()->iScanCode == 167)
{
iMconnect->SendClose();
}
break;
}
}
Draw();
iWs.Flush();
WaitWgEvent();
}
示例3: FEP
/**
@SYMTestCaseID UIF-FEPTEST-0001
@SYMPREQ 0000
@SYMTestCaseDesc Launch the application and offer events.
@SYMTestPriority High
@SYMTestStatus Implemented
@SYMTestActions Launch an application with the editor window. The application is made to exit, when a timer expires.
Load the FEP (TFEP1). Create character codes for text events. Offer the texts to the applciation for
the TFEP1 to intercept.
A succesful implementation ensures that the application exits without a crash.
Here the layout of the FEP UI is such that the Composition Window is integrated into the Target Control.
@SYMTestExpectedResults The test case fails if the app crashed with an exception and passes if the app exits cleanly
*/
void CDefocusingEdwinUi::RunTestStepL(TInt aStep)
{
User::After(TTimeIntervalMicroSeconds32(1));
TTimeIntervalSeconds theInterval;
TTime tm;
tm.HomeTime();
tm.SecondsFrom(iTmStart,theInterval);
TInt theInt = theInterval.Int();
if(iCurrentSecond < theInt)
{
if(KNumberOfSeconds-iCurrentSecond < 0)
{
iCoeEnv->InstallFepL(KNullUid);
AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
return;
}
else
{
TBuf<100> message;
message.Format(_L("%d seconds remaining"), KNumberOfSeconds-iCurrentSecond);
User::InfoPrint(message);
iCurrentSecond = theInt;
}
}
TWsEvent theEvent;
TKeyEvent *theKey = theEvent.Key();
theKey->iScanCode = 0;
theKey->iModifiers= 0;
theKey->iRepeats=0;
theKey->iCode = 'A';
TInt nRes = aStep % 7;
if(nRes == 6)
{
theKey->iCode = EKeyEnter;
}
else
{
theKey->iCode += nRes;
}
INFO_PRINTF2(_L("Simulate Key Event with code %d"), theKey->iCode);
SendEventToWindowGroups(theEvent);
}
示例4: if
void CMicroDialog::CMicroDialogInt::EventLoopL(void)
{
TRequestStatus eventStatus,timerStatus;
iWsSession.EventReady(&eventStatus);
iTimer.After(timerStatus,100000);
iDoLoop=ETrue;
TInt focus=EFalse;
while(iDoLoop)
{
User::WaitForAnyRequest();
if(eventStatus.Int()!=KRequestPending)
{
User::LeaveIfError(eventStatus.Int());
TWsEvent event;
iWsSession.GetEvent(event);
switch(event.Type())
{
case EEventFocusLost:
focus=EFalse;
break;
case EEventFocusGained:
focus=ETrue;
break;
case EEventFocusGroupChanged:
if(iWsSession.GetFocusWindowGroup()==iOwner->iId)
iRootWin.SetOrdinalPosition(0);
break;
case EEventKey:
iOwner->iCallback->MicroDialogKey(*(event.Key()));
break;
}
iWsSession.EventReady(&eventStatus);
}
else if(timerStatus.Int()!=KRequestPending)
{
User::LeaveIfError(timerStatus.Int());
if(focus) iOwner->iCallback->MicroDialogTimer();
iTimer.After(timerStatus,100000);
}
else
{
iOwner->iCallback->MicroDialogRequest();
}
}
iTimer.Cancel();
iWsSession.EventReadyCancel();
}
示例5: EPOC_HandleWsEvent
int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
{
int posted = 0;
SDL_keysym keysym;
// SDL_TRACE1("hws %d", aWsEvent.Type());
switch (aWsEvent.Type())
{
case EEventPointer: /* Mouse pointer events */
{
const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode();
if(mode == EPointerCursorNone)
{
return 0; //TODO: Find out why events are get despite of cursor should be off
}
const TPointerEvent* pointerEvent = aWsEvent.Pointer();
TPoint mousePos = pointerEvent->iPosition;
/*!! TODO Pointer do not yet work properly
//SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!!
if (Private->EPOC_ShrinkedHeight) {
mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height
}
if (Private->EPOC_ShrinkedWidth) {
mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width
}
*/
posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
switch (pointerEvent->iType)
{
case TPointerEvent::EButton1Down:
posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
break;
case TPointerEvent::EButton1Up:
posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
break;
case TPointerEvent::EButton2Down:
posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
break;
case TPointerEvent::EButton2Up:
posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
break;
case TPointerEvent::EButton3Down:
posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);
break;
case TPointerEvent::EButton3Up:
posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
break;
} // switch
break;
}
case EEventKeyDown: /* Key events */
{
#ifdef SYMBIAN_CRYSTAL
// special case: 9300/9500 rocker down, simulate left mouse button
if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
{
const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode();
if(mode != EPointerCursorNone)
posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
}
#endif
(void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym);
#ifndef DISABLE_JOYSTICK
/* Special handling */
switch((int)keysym.sym) {
case SDLK_CAPSLOCK:
if (!isCursorVisible) {
/* Enable virtual cursor */
HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
}
else {
/* Disable virtual cursor */
HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
}
isCursorVisible = !isCursorVisible;
break;
}
#endif
posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
break;
}
case EEventKeyUp: /* Key events */
{
#ifdef SYMBIAN_CRYSTAL
// special case: 9300/9500 rocker up, simulate left mouse button
if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
{
posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
}
//.........这里部分代码省略.........
示例6: EPOC_HandleWsEvent
int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
{
int posted = 0;
SDL_keysym keysym;
switch (aWsEvent.Type()) {
case EEventPointer: /* Mouse pointer events */
{
const TPointerEvent* pointerEvent = aWsEvent.Pointer();
TPoint mousePos = pointerEvent->iPosition;
//SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!!
if (Private->EPOC_ShrinkedHeight) {
mousePos.iY <<= 1; /* Scale y coordinate to shrinked screen height */
}
posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
if (pointerEvent->iType==TPointerEvent::EButton1Down) {
posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
}
else if (pointerEvent->iType==TPointerEvent::EButton1Up) {
posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
}
else if (pointerEvent->iType==TPointerEvent::EButton2Down) {
posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
}
else if (pointerEvent->iType==TPointerEvent::EButton2Up) {
posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
}
//!!posted += SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(aWsEvent.Key()->iScanCode, &keysym));
break;
}
case EEventKeyDown: /* Key events */
{
(void*)TranslateKey(aWsEvent.Key()->iScanCode, &keysym);
/* Special handling */
switch((int)keysym.sym) {
case SDLK_CAPSLOCK:
if (!isCursorVisible) {
/* Enable virtual cursor */
HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
}
else {
/* Disable virtual cursor */
HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
}
isCursorVisible = !isCursorVisible;
break;
}
posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
break;
}
case EEventKeyUp: /* Key events */
{
posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(aWsEvent.Key()->iScanCode, &keysym));
break;
}
case EEventFocusGained: /* SDL window got focus */
{
//Private->EPOC_IsWindowFocused = ETrue;
/* Draw window background and screen buffer */
RedrawWindowL(_this);
break;
}
case EEventFocusLost: /* SDL window lost focus */
{
//Private->EPOC_IsWindowFocused = EFalse;
// Wait and eat events until focus is gained again
/*
while (ETrue) {
Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
User::WaitForRequest(Private->EPOC_WsEventStatus);
Private->EPOC_WsSession.GetEvent(Private->EPOC_WsEvent);
TInt eventType = Private->EPOC_WsEvent.Type();
Private->EPOC_WsEventStatus = KRequestPending;
//Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus);
if (eventType == EEventFocusGained) {
RedrawWindowL(_this);
break;
}
}
*/
break;
}
case EEventModifiersChanged:
{
TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged();
TUint modstate = KMOD_NONE;
if (modEvent->iModifiers == EModifierLeftShift)
modstate |= KMOD_LSHIFT;
//.........这里部分代码省略.........
示例7: HandleWsEvent
// -----------------------------------------------------------------------------
// CGameController::HandleWsEvent
// This function is called by the CWsEventReceiver
// Active Object, whenever it receives a Windows Server
// event.
// -----------------------------------------------------------------------------
//
void CGameController::HandleWsEvent( const TWsEvent& aWsEvent )
{
TInt eventType = aWsEvent.Type();
// Handle Key and Screen Size change Events.
switch( eventType )
{
case EEventKeyDown:
{
if( iGame )
iGame->HandleKeyEvent( aWsEvent.Key()->iScanCode, EFalse );
break;
}
case EEventKeyUp:
{
if( iGame )
iGame->HandleKeyEvent( aWsEvent.Key()->iScanCode, ETrue );
break;
}
case( EEventScreenDeviceChanged ): // The screen size has changed.
{
TPixelsTwipsAndRotation pixnrot;
iWsScreenDevice->GetScreenModeSizeAndRotation(
iWsScreenDevice->CurrentScreenMode(),
pixnrot
);
if( pixnrot.iPixelSize != iWindow->Size() )
{
// Update the window.
iWindow->SetExtent( TPoint( 0, 0 ),
pixnrot.iPixelSize
);
// If a game is running, notify it about the change.
if( iGame )
{
iGame->SetScreenSize( pixnrot.iPixelSize.iWidth,
pixnrot.iPixelSize.iHeight
);
// Call eglSwapBuffers after the window size has changed.
// This updates the window size used by egl.
eglSwapBuffers( iEglDisplay, iEglSurface );
}
}
break;
}
case EEventFocusLost:
{
iIsAppInFocus = EFalse;
break;
}
case EEventFocusGained:
{
iIsAppInFocus = ETrue;
break;
}
case EEventWindowVisibilityChanged:
{
// Check if the event is for the iWindow
if( aWsEvent.Handle() ==
reinterpret_cast<TUint32>( this )
)
{
if( aWsEvent.VisibilityChanged()->iFlags &
TWsVisibilityChangedEvent::ECanBeSeen
)
{
iIsVisible = ETrue;
}
else
iIsVisible = EFalse;
}
break;
}
case EEventNull:
case EEventKey:
case EEventUser:
case EEventWindowGroupListChanged:
case EEventModifiersChanged:
case EEventSwitchOn:
case EEventPassword:
case EEventWindowGroupsChanged:
case EEventErrorMessage:
case EEventPointer:
case EEventPointerEnter:
case EEventPointerExit:
//.........这里部分代码省略.........
示例8: KeyUpEvent
LOCAL_C TInt KeyUpEvent(_THIS, const TWsEvent& aWsEvent)
{
SDL_keysym keysym;
TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym);
return SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
}
示例9: EPOC_HandleWsEvent
int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
{
int posted = 0;
SDL_keysym keysym;
// SDL_TRACE1("hws %d", aWsEvent.Type());
switch (aWsEvent.Type())
{
case EEventPointer: /* Mouse pointer events */
{
/* const TPointerCursorMode mode = EpocSdlEnv::PointerMode();
if(mode == EPointerCursorNone)
{
return 0; //TODO: Find out why events are get despite of cursor should be off
}
*/
const TPointerEvent* pointerEvent = aWsEvent.Pointer();
const TPoint mousePos = EpocSdlEnv::WindowCoordinates(pointerEvent->iPosition);
/*!! TODO Pointer do not yet work properly
//SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!!
if (Private->EPOC_ShrinkedHeight) {
mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height
}
if (Private->EPOC_ShrinkedWidth) {
mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width
}
*/
posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */
switch (pointerEvent->iType)
{
case TPointerEvent::EButton1Down:
posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
break;
case TPointerEvent::EButton1Up:
posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
break;
case TPointerEvent::EButton2Down:
posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
break;
case TPointerEvent::EButton2Up:
posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
break;
case TPointerEvent::EButton3Down:
posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);
break;
case TPointerEvent::EButton3Up:
posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
break;
} // switch
break;
}
case EEventKeyDown: /* Key events */
{
#ifdef SYMBIAN_CRYSTAL
// special case: 9300/9500 rocker down, simulate left mouse button
if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
{
const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode();
if(mode != EPointerCursorNone)
posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
}
#endif
(void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym);
#ifndef DISABLE_JOYSTICK
/* Special handling */
switch((int)keysym.sym) {
case SDLK_CAPSLOCK:
if (!isCursorVisible) {
/* Enable virtual cursor */
HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible);
}
else {
/* Disable virtual cursor */
HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible);
}
isCursorVisible = !isCursorVisible;
break;
}
#endif
posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
break;
}
case EEventKeyUp: /* Key events */
{
#ifdef SYMBIAN_CRYSTAL
// special case: 9300/9500 rocker up, simulate left mouse button
if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA)
{
posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
}
//.........这里部分代码省略.........
示例10: SetupL
void CWsGceCscBase::SetupL()
{
iDoTearDown=ETrue;
iRed.SetInternal(0xFFFF0000);
iGreen.SetInternal(0xFF00FF00);
iBlue.SetInternal(0xFF0000FF);
iCyan.SetInternal(0xFF00FFFF);
iMagenta.SetInternal(0xFFFF00FF);
iYellow.SetInternal(0xFFFFFF00);
iWhite.SetInternal(0xFFFFFFFF);
ASSERT_EQUALS_X(iSession.Connect(), KErrNone);
{//Stolen from TAuto CloseAllPanicWindows()
TInt idFocus = iSession.GetFocusWindowGroup();
TWsEvent event;
event.SetType(EEventKey); //EEventKeyDown
TKeyEvent *keyEvent = event.Key();
keyEvent->iCode = EKeyEscape;
keyEvent->iScanCode = EStdKeyEscape;
keyEvent->iModifiers = 0;
TInt theLimit = 50;
while(idFocus != NULL && (theLimit-- > 0))
{
iSession.SendEventToAllWindowGroups(event);
TInt idNewFocus = iSession.GetFocusWindowGroup();
if (idNewFocus!=idFocus)
{
INFO_PRINTF1(_L("A window was closed [probably a panic box from the previous test]."));
}
idFocus=idNewFocus;
}
}
TInt err = KErrNone;
TRAP(err, iScreenDevice = new (ELeave) CWsScreenDevice(iSession));
PRINT_ON_ERROR2_L(err, _L("Failed to create screen device: %d"), err);
ASSERT_EQUALS_X(iScreenDevice->Construct(TGlobalSettings::Instance().iScreen), KErrNone);
iDisplayMode = iScreenDevice->DisplayMode(); // Get default display mode
TRAP(err, iGc = new (ELeave) CWindowGc(iScreenDevice));
PRINT_ON_ERROR2_L(err, _L("Failed to create graphics context: %d"), err);
ASSERT_EQUALS_X(iGc->Construct(), KErrNone);
iGroup = RWindowGroup(iSession);
ASSERT_EQUALS_X(iGroup.Construct(++iWindowHandle,iScreenDevice), KErrNone);
iSession.Flush();
RWindow testTrans(iSession);
ASSERT_EQUALS_X(testTrans.Construct(iGroup, ++iWindowHandle), KErrNone);
iTransparencyEnabled=(testTrans.SetTransparencyFactor(iWhite)==KErrNone);
testTrans.Close();
//clean-up if previous test abended
if (PostTestCleanupInstance().iSharedUtility)
{
//Temp removed - may be causing ONB fails!
// if (PostTestCleanupInstance().iSharedUtility->DestroyAll())
// {
// INFO_PRINTF1(_L("Destroyed some surfaces from previous test."));
//
// }
}
if (!PostTestCleanupInstance().iCleanedUpOnExit)
PostTestCleanupInstance().iCleanedUpOnExit=EFalse;
if (!GCEIsSupported())
{
INFO_PRINTF1(_L("Some Setup skipped: GCE support is not loaded"));
return;
}
TRAPD(err_FailedToCreateSurfaceUtility, iUtility = CSurfaceUtility::NewL( PostTestCleanupInstance().iSharedUtility));
ASSERT_EQUALS(err_FailedToCreateSurfaceUtility,KErrNone);
}