函数:fwGetPressedButton 获取按钮点击事件

函数功能:用于获取点击按钮事件

引擎版本:iOS v2.3.5,Android v2.0.3 以上

函数方法

vid,kind = fwGetPressedButton();

返回值 类型 说明
vid string 返回显示按钮的 ID
kind number 0 - 默认获取点击事件填,1 - 则获取长按事件,
仅支持引擎版本Androidv3.2.0、iOSv3.1.5 及其以上版本

函数用例

local num = 0;
fwShowWnd("wid",100,100,500,500,1);
fwShowTextView("wid","id1","点击 :" .. num,"center","FF0000","FFDAB9",15,0,0,0,200,200);
fwShowTextView("wid","id2","闪","center","FFFFFF","0000FF",15,0,300,0,400,100,{alpha = 0.5,radius = 50});
fwShowWnd("wida",300,300,500,500,1);
fwShowButton("wida","vid","点我","FFFFFF","FF0000","",15,0,0,100,100,{alpha = 0.5,radius = 50});
while (true) do
     --vid 和 kind 仅支持引擎版本Androidv3.2.0 及其以上版本
    local vid,kind = fwGetPressedButton();
    if vid == "vid" then
        num = num + 1
        if kind == 1 then
              --alpha 和 radius 仅支持引擎版本Androidv3.2.0 及其以上版本
            fwShowTextView("wid","id1","点击 :" .. num,"center","FF0000","FFDAB9",15,0,0,0,200,200);
            if num%2 == 0 then
                fwShowTextView("wid","id2","闪","center","FFFFFF","0000FF",15,0,300,0,400,100);
            else
                fwCloseView("wid","id2");
            end
        else
            fwShowTextView("wid","id1","长按 :" .. num,"center","FF0000","FFDAB9",15,0,0,0,200,200);
            if num%2 == 0 then        fwShowTextView("wid","id2","闪","center","FFFFFF","0000FF",15,0,300,0,400,100);
            else
                fwCloseView("wid","id2");
            end
        end 
    end
end

完整实例

init(0)
toast("创建一个可移动的窗口");
fwShowWnd("window1",0,0,200,200,1); --创建一个可移动的窗口
mSleep(5000);
toast("加载文字");
--引擎版本 iOS v3.0.9 及其以上版本,子窗口视图大小不能超出父窗口载体,超出部分不显示
--引擎版本 iOS v3.0.9 及其以上版本,假如文字内容过多超出父窗口载体,末尾不显示省略号
fwShowTextView("window1","text1","这是一个文本视图","center","FF0000","FFDAB9",15,0,0,0,200,100,0.5)
mSleep(5000);
toast("加载一个截图");
snapshot("1.png",400,400,600,500);
fwShowImageView("window1","img1","1.png",0,100,200,200);
mSleep(5000);
toast("随便移动窗口,5 秒后继续");
mSleep(5000);
tab=fwGetWndPos("window1")
dialog("窗口获取状态:"..tab.ret.."\n".."左上角坐标:"..tab.x..","..tab.y.."\n".."右下角坐标:"..tab.x1..","..tab.y1, 2);
mSleep(2000);
toast("关闭文字视图");
fwCloseView("window1","text1"); --关闭文字视图
mSleep(2000);
toast("关闭窗口");
fwCloseWnd("window1");
Copyright 北京帮你玩科技有限公司 2024 all right reserved,powered by Gitbook该文章修订时间: 2024-10-08 11:38:05

results matching ""

    No results matching ""