×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    35

    How to capture any key pressed or Screen is touched for touch screen in Non UI app

    Hello Friends

    How to get event/notification for any key press or screen is touched in Non UI application.

    Please suggest some links or piece of code.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: How to capture any key pressed or Screen is touched for touch screen in Non UI ap

    "Any" is not really possible, but you can use CaptureKey for getting keypresses when your application is not visible (either non-GUI or GUI). Search for it in the Wiki, and you can find a really simple test code in http://www.developer.nokia.com/Commu...is-key-capture, which may help in understanding the Wiki example too.
    Capturing screen touches is not really supported as I know. You can experiment having some top-priority invisible window, but it is not trivial at least.

  3. #3
    Registered User
    Join Date
    Jun 2011
    Posts
    35

    Re: How to capture any key pressed or Screen is touched for touch screen in Non UI ap

    Hi Wizard

    I have displayed an image using exact code at http://www.developer.nokia.com/Commu...tion_framework. I want to capture pointer events when displayed image is at top.

    is it possibly in this scenario.

    Note: I am not using any custom control.

  4. #4
    Registered User
    Join Date
    Jun 2011
    Posts
    35

    How to capture pointer events ... Its urgent please

    Friends,

    I have to capture pointer events in the following Scenario.

    1.In a NON UI application i have displayed an image.

    2. I need to be notified when user touches the screen so that i can remove/close image.

    For reference i have pasted the code i am using to display an image

    #include <apgwgnam.h> //CApaWindowGroupName
    #include "WindowDrawer.h"
    #include <coedef.h> //for ECoeWinPriorityAlwaysAtFront

    CWindowDrawer* CWindowDrawer::NewL(void)
    {
    CWindowDrawer* self = CWindowDrawer::NewLC(void);
    CleanupStack::Pop(self);
    return self;
    }


    CWindowDrawer* CWindowDrawer::NewLC(void)
    {
    CWindowDrawer* self = new (ELeave) CWindowDrawer(void);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

    // the active object priority should be relatively low
    CWindowDrawer::CWindowDrawer(void):CActive(EPriorityLow)
    {
    }

    CWindowDrawer::~CWindowDrawer()
    {
    Cancel();

    if(iMyFont)
    {
    iScreenDevice->ReleaseFont(iMyFont);
    iMyFont = NULL;
    }

    delete iWindowGc;
    iWindowGc = NULL;
    delete iScreenDevice;
    iScreenDevice = NULL;

    iWindow.Close();

    iWindowGroup.Close();
    iWsSession.Close();
    }

    void CWindowDrawer::ConstructL(void)
    {
    CActiveScheduler::Add(this);

    User::LeaveIfError(iWsSession.Connect());

    iScreenDevice=new (ELeave) CWsScreenDevice(iWsSession);
    User::LeaveIfError(iScreenDevice->Construct());
    User::LeaveIfError(iScreenDevice->CreateContext(iWindowGc));

    TFontSpec MyeFontSpec (KFontArial, 12*15);
    MyeFontSpec.iTypeface.SetIsProportional(ETrue);
    User::LeaveIfError(iScreenDevice->GetNearestFontInTwips(iMyFont,MyeFontSpec));

    iWindowGroup=RWindowGroup(iWsSession);
    User::LeaveIfError(iWindowGroup.Construct((TUint32)&iWindowGroup, EFalse));
    // iWindowGroup.SetOrdinalPosition(0,ECoeWinPriorityNormal);
    iWindowGroup.SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront);
    iWindowGroup.EnableReceiptOfFocus(EFalse);

    CApaWindowGroupName* winGroupName=CApaWindowGroupName::NewLC(iWsSession);
    winGroupName->SetHidden(ETrue);
    winGroupName->SetWindowGroupName(iWindowGroup);
    CleanupStack::PopAndDestroy();

    iWindow=RWindow(iWsSession);
    User::LeaveIfError(iWindow.Construct(iWindowGroup, (TUint32)&iWindow));

    TPixelsTwipsAndRotation SizeAndRotation;
    iScreenDevice->GetDefaultScreenSizeAndRotation(SizeAndRotation);

    iWindow.Activate();
    iWindow.SetExtent(TPoint(0,0),SizeAndRotation.iPixelSize);
    iWindow.SetBackgroundColor(KRgbBlue);
    // iWindow.SetOrdinalPosition(0,ECoeWinPriorityNormal);
    iWindow.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
    iWindow.SetNonFading(ETrue);
    iWindow.SetVisible(ETrue);

    Draw();
    iWsSession.RedrawReady(&iStatus);
    SetActive();
    }

    void CWindowDrawer::RunL()
    {
    if (iStatus != KErrCancel)
    {
    TWsRedrawEvent e;
    iWsSession.GetRedraw(e);

    // if Windows Server does not want a redraw the window handle is 0
    if (e.Handle() != 0)
    {
    // draw our only window
    Draw();
    }

    iWsSession.RedrawReady(&iStatus);
    SetActive();
    }
    }

    void CWindowDrawer::Draw(void)
    {
    iWindowGc->Activate(iWindow);

    TRect DrwRect(TPoint(0,0), iWindow.Size());

    iWindow.Invalidate(DrwRect);
    iWindow.BeginRedraw();
    iWindowGc->Clear(DrwRect);

    if(iMyFont)
    {
    iWindowGc->UseFont(iMyFont);

    TInt StartY ((DrwRect.Height() - iMyFont->HeightInPixels()) / 2);

    iWindowGc->DrawText(KtxHelloThere,TRect(0,StartY,DrwRect.Width(),(StartY + iMyFont->HeightInPixels())),iMyFont->AscentInPixels(), CGraphicsContext::ECenter, 0);
    }

    iWindow.EndRedraw();

    iWindowGc->Deactivate();
    iWsSession.Flush();
    }

    void CWindowDrawer::DoCancel()
    {
    iWsSession.RedrawReadyCancel();
    }

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: How to capture pointer events ... Its urgent please

    Pointer events are just simple Window Server events. You can get Window Server events via RWsSession::EventReady+GetEvent.
    Note that this is not called capturing, that is why it may work without any wild hack.

  6. #6
    Registered User
    Join Date
    Jun 2011
    Posts
    35

    Re: How to capture pointer events ... Its urgent please

    Thnx i could get pointer events successfully.

    What if i want to receive key press events in addition to pointer events? What should i do to receive any key press event.

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: How to capture pointer events ... Its urgent please

    If your window is focused, keypresses are WS events too.
    If your window is not focused, CaptureKey, as suggested in #2 already.

  8. #8
    Registered User
    Join Date
    Jun 2011
    Posts
    35

    Re: How to capture pointer events ... Its urgent please

    Is there any way to disable all notification programatically

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,740

    Re: How to capture pointer events ... Its urgent please

    "All"? Probably there is no way for that.

  10. #10
    Registered User
    Join Date
    Jun 2011
    Posts
    35

    Re: How to capture pointer events ... Its urgent please

    actaully some of applications are hiding or managed to disable "Data packet connectio onhold/active" notification, low charging and charger plug in. May hide atleast these three notifications

    1. Packet data connection on hold

    2. Charging is low.

    3. Notification while we plugin charger

  11. #11
    Registered User
    Join Date
    Jun 2011
    Posts
    35

    Re: How to capture pointer events ... Its urgent please

    Hi again.

    I have been facing a strange issue.

    I could successsfully display an image over call buble. After fresh installation of my application on Nokia 5800. I could display image as many times as i call. Butttttttttt when i restart phone then i could never display image rather application crashes.

    Please suggest what should i do?
    For reference i have already posted my code plz see in #4.

Similar Threads

  1. how to create app for touch and non touch events?
    By maniohile in forum Mobile Java General
    Replies: 2
    Last Post: 2011-04-28, 06:44
  2. convert code for key pressed phone to screen touch phones
    By napsteratwork in forum Mobile Java General
    Replies: 5
    Last Post: 2011-03-21, 08:37
  3. Replies: 1
    Last Post: 2010-01-13, 11:29
  4. how to capture keys for touch screen (5800 XP)
    By nital_shah in forum Symbian
    Replies: 1
    Last Post: 2009-04-14, 10:30
  5. Application is closed when a key is pressed or screen saver is running
    By lss0986 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-04-12, 07:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×