How to create a floating window and detect touch event
I created a floating window with this code, but i don't know how to detect when user touches it, or to get pointer position on this window when user touches it.
[code]
User::LeaveIfError(ws.Connect());
screen = new(ELeave) CWsScreenDevice(ws);
screen->Construct();
RWindowGroup wg(ws);
User::LeaveIfError(wg.Construct(reinterpret_cast<TUint32>(&wg), EFalse));
CleanupClosePushL(wg);
wg.SetOrdinalPosition(10, ECoeWinPriorityAlwaysAtFront);
CWindowGc* gc;
User::LeaveIfError(screen->CreateContext(gc));
CleanupStack::PushL(gc);
RWindow window(ws);
User::LeaveIfError(window.Construct(wg, reinterpret_cast<TUint32>(&wg) + 1));
CleanupClosePushL(window);
window.SetBackgroundColor(TRgb(0x90, 0x90, 0x90));
window.Activate();
window.SetExtent(TPoint(0, 0), TSize(50, 300));
window.SetVisible(ETrue);
gc->Activate(window);
TRect rect = TRect(window.Size());
window.Invalidate(rect);
window.BeginRedraw(rect);
gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
gc->Clear();
gc->SetBrushColor(TRgb(0, 255, 0));
gc->DrawRect(rect);
window.EndRedraw();
gc->Deactivate();
ws.Flush();
[/code]
thanks.
Re: How to create a floating window and detect touch event
You should check HandlePointerEventL()... it will let you know of the touch events.
Re: How to create a floating window and detect touch event
But how could I bind iWindow with HandlePointerEventL() ??
Is there a function under RWindow I can pass it a callback object to receive pointer event??
Re: How to create a floating window and detect touch event
Yep, she basically though that you are using normal application framework. anyway, you should first make a real class instance for handling the screen and derive it from CActive, a bit like this: [url]http://www.developer.nokia.com/Community/Wiki/TSS000642_-_Using_drawable_windows_without_application_framework[/url]
then you could use the RWsSession's EventReady (instead of the example RedrawReady) to catch all events, also do remember to enable focus for your window.
Re: How to create a floating window and detect touch event
Also look at the following method : [B]RWindow::SetPointerCapture() [/B]
Re: How to create a floating window and detect touch event
hi guys, and girls,
I managed to get my code work , and i can detect when user touches the window, and the (x,y) point.
[B]My problem is, how to detect when user touches the screen out of my floating window, so I can dismiss it?[/B]
Re: How to create a floating window and detect touch event
if you plan to disable the screen, you should make transparent window that fills the whole screen.
Re: How to create a floating window and detect touch event
No, I'm not planning to disable the whole screen, i just want to show my floating window ( it will be as a task bar, in screen corner ), and if user clicks it, it will launch an application and disappear, and if user click out / away from my window, it will just disappear.
Re: How to create a floating window and detect touch event
So in that case you could also use the method I descriped, then of cource the touch event used for the dismissing would be lost, unless you find a way to forward it.
Re: How to create a floating window and detect touch event
How did you get it working, could you please share some of the code with me(us) as I am trying to make something similar.
Re: How to create a floating window and detect touch event
You could maybe just try out the code in the link, and then describe what the problem you still have is.