【问题标题】:Detect if the Button is Enabled or Disabled in Livecode检测按钮在 Livecode 中是启用还是禁用
【发布时间】:2015-01-01 03:34:01
【问题描述】:

如何检测按钮是否在 livecode 中启用/禁用?

我想显示一个警报框来确定按钮是否被禁用/启用。

我尝试了这些脚本,但它不起作用...

if button "button" is disabled then
   answer "button is disabled"
else
   answer "button is enabled"
end if

【问题讨论】:

  • 投反对票的人应该添加评论来解释原因!

标签: button detect livecode


【解决方案1】:

首先,我注意到您的所有脚本行都以大写字母开头。我建议您以小写字符开头。对于 LiveCode 脚本中非常典型的驼峰大写语法,这将为您提供更大的灵活性。

您无法将控件与常量进行比较。常量基本上是一个字符串,您只能将字符串与字符串进行比较。因为按钮是控件而不是字符串,所以不能比较按钮和常量。

其次,disabled 是一个属性,而不是一个常数。在你的脚本中,你对待就像一个常数。除非是全局属性,否则属性始终是“控件的”。这意味着您需要在语法中包含“of”。你可以写the disabled of button "name of your button"。请不要使用“按钮”作为按钮的名称,因为最终这可能会混淆您和 LiveCode 引擎。

以下脚本应该可以工作。

if the disabled of button "My Button" is true then
  answer "The button is disabled"
else
  answer "The button is enabled"
end if

因为the disabled of button "My Button" 返回truefalse 并且the disabled of button "My Button" is true 也计算为truefalse,所以您也可以只写

if the disabled of button "My Button" then
  answer "The button is disabled"
else
  answer "The button is enabled"
end if

【讨论】:

  • 谢谢,我编辑了我的问题。我正在使用电话发布此问题,因此我的代码以大写字母开头。
猜你喜欢
  • 2013-09-29
  • 2020-03-28
  • 1970-01-01
  • 2011-08-02
  • 1970-01-01
  • 1970-01-01
  • 2012-11-06
  • 2014-08-16
  • 1970-01-01
相关资源
最近更新 更多