=====================================================================
Hi,
I'm trying to program the copy/paste feature of text apps. in Nokia.
When pressing the "ABC" key, I want options to appear (copy/paste) just like on the apps.
I'm currently catching key presses like this:
Code:
TKeyResponse Take3ContainerDay::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
{
TBool m_bRepeated = EFalse;
// This is used to capture the "Pencil (ABC)" button click
TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift);
if (shiftKeyPressed)
{
if(aKeyEvent.iRepeats == 1)
m_bRepeated = ETrue;
else
m_bRepeated = EFalse;
if (m_bRepeated)
{
// Do something
}
}
}
The above code catches the "ABC" button click event.
But iRepeats NEVER goes above 0, when on the emulator I keep it pressed.
Any suggestions?
--------------------------------------------------------------------------------
--------------------
Roy Weinberg:
You need to CaptureLongKey.
If I am not mistaken, iRepeats is set only if you captured the long key press. And depending on the flags set for the very long press you can get either a number of iRepeats==1 events or a single iRepeats==N event.
--------------------------------------------------------------------------------
Compilable Symbian Code Examples
m00gl3:
Thanks for the swift reply!
I've read about the "CaptuteLongKey", and also looked at the example on the site you've linked in your post.
However,
I did not quite understand how to incorporate that into my code.
1) If I'm using OfferKeyEventL to capture key events, where would I put the code to capture the Long key? (and before that - by the example - to run the CaptureKey).
Do I put that code inside hte OfferKeyEventL?
Also,
What If I don't want to capture the long key for the "ABC" key outside of my application? I've read that this solution (in the example) will make it so that my application catches the long key, even if it is set in the background, and another application is trying to access that key.
Do I need to put the "Stop capturing key" at the end of OfferKeyEvenetL?
2) How do I show the different menus (on the left and right butons) for "Copy" and "Paste" - and associate that with the long key press?
I know I need to add a resource to the RSS file - but how do I connect beween that and capturing heh long key press?
Thank you SOOO much for taking the time to reply!
--------------------------------------------------------------------------------
--------------------
Roy Weinberg:
Hi did you get solution? even i am having same problem. If you get plese reply
eric:
That code has nothing to do with OfferKeyEventL. It is just a tip to capture keyevent outside of a CCoeControl object.
If you want to capture long press, do it either:
- through the iRepeat data member
- by measuring the time between KeyUp and KeyDown events.
In both case, this should (probably) be done in OfferKeyEventL.