iRepeats vs. CaptureLongKey


=====================================================================
 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.

 
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值