5th 触摸屏震动
我在程序中自定义的button和list,怎么能让他们响应系统的触摸屏震动? --------------------编程问答-------------------- 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.
补充:移动开发 , Symbian