TouchGFX之Button

TouchGFX中的按钮是一种感应触控事件的控件,能够在按钮被按下/释放时发送回调

代码

#ifndef TOUCHGFX_ABSTRACTBUTTON_HPP
#define TOUCHGFX_ABSTRACTBUTTON_HPP
#include 
#include 
#include 

namespace touchgfx
{
/* 按键抽象接口类 */
class AbstractButton : public Widget
{
public:
	/* 构造函数 */
	AbstractButton() : Widget(), action(), pressed(false)
	{
		setTouchable(true);	//打开触摸功能
	}

	/* 点击事件处理函数 */
	virtual void handleClickEvent(const ClickEvent& event);

	/* 设置点击事件回调函数 */
	void setAction(GenericCallback& callback)
	{
		action = &callback;
	}

	/* 执行点击事件回调函数 */
	virtual void executeAction()
	{
		if (action && action-&g

你可能感兴趣的:(STM32,arm开发)