×
Namespaces

Variants
Actions

在触屏UI应用程序中给予触摸反馈

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

兼容于
平台: S60 5th Edition
S60 5th Edition

文章
翻译:
最后由 hamishwillee 在 28 Nov 2012 编辑
  • 详细描述

触摸反馈是在触摸屏幕交互成功后给予用户一种物理反馈(震动)。我们可以在注册时增加,修改或移除反馈区域。在注册时可以选择打开此功能,MTouchFeedback可以取得触摸反馈示例的指针。

下列代码自签名即可执行。

Contents

MMP

需要下列链接库和能力:

CAPABILITY  None       
 
LIBRARY touchfeedback.lib


头文件

需要包含两个头文件

#include <touchfeedback.h>
#include <touchlogicalfeedback.h>
 
class CImageConverterContainer : public CCoeControl,
public MCoeControlObserver, public MAknLongTapDetectorCallBack
{
...
private:
MTouchFeedback* iTouchFeedBack;
...
}


源文件

// Create an instance of touch feedback
void CImageConverterContainer::ConstructL(const TRect& /*aRect*/)
{
...
iTouchFeedBack = MTouchFeedback::Instance();
iTouchFeedBack->SetFeedbackEnabledForThisApp(ETrue);
...
}
 
// Give some vibra to the user when a pointer down event occurs
void CImageConverterContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
{
...
if (aPointerEvent.iType == TPointerEvent::EButton1Down)
{
// Give feedback to user (vibration)
iTouchFeedBack->InstantFeedback(ETouchFeedbackBasic);
}
...
}


MTouchFeedback::InstantFeedback()的参数

*  ETouchFeedbackNone      - Use for disabling feedback for some areas of the
* window when using area registry.
*
* ETouchFeedbackBasic - Use as default feedback for pen down events.
* For example, pressing a button or tab.
*
* ETouchFeedbackSensitive - Sensitive feedback situations
* where the triggering action is not very
* important (e.g. change focus in list), or when
* there can be a large amount of feedback in
* a short time (e.g. text selection which gives
* feedback on every new selected character).
* Also used for scrolling and dragging.


后记

当使用触摸笔或手指划过按下屏幕时即可得到震动反馈。

This page was last modified on 28 November 2012, at 08:41.
67 page views in the last 30 days.
×