私は前にこの問題を抱えていましたが、何らかの理由でこのコードを使用すると、この問題が発生することはありません。彼らがこの問題を解決したかどうかはわかりませんが、コードの後に私はあなたが主に使う解決策を2つ与えます。
local widget = require("widget")
local function button1Press(event)
local alert = native.showAlert("Corona", "BIG", { "OK"})
print ("Big")
end
local function buttonHandler(event)
local alert = native.showAlert("Corona", "Small", { "OK"})
end
local button1 = widget.newButton
{
defaultFile = "buttonRed.png",
overFile = "buttonRedOver.png",
label = "Button 1 Label",
emboss = true,
onPress = button1Press,
}
local buttonArrow = widget.newButton
{
id = "arrow",
defaultFile = "buttonArrow.png",
overFile = "buttonArrowOver.png",
onPress = buttonHandler,
}
button1.x = 160; button1.y = 160
buttonArrow.x = 250; buttonArrow.y = 160
それが仕事doesntの場合:ボタンによって返される関数の最後に一番上のボタンで
1-「trueを返す」を含みます。彼らは、これがタッチイベントを受け取ったトップの下のオブジェクトを停止すると言う。私はこれを使うのが難しく、うまくいかないかもしれません。
2-上記が機能しない場合。この単純な回避策を使用してください。単にボタンがタッチされたかどうかをチェックします。
lowerbutCheck = true
local function upperButton(event)
--your code
lowerbutChecked=false
end
local function lowerButton(event)
if lowerbutChecked then
--do your code
else
--do nothing
end
lowerbutChecked=true
end
どちらの場合も両方のボタンをクリックしていますか(これらの2つは完全に重複していますか)。 – Amir
いいえ、別の大きなボタンの上にある小さなボタンです(実際は大きなボタンの隅にあるヘルプボタンです)。 – FICHEKK
http://stackoverflow.com/questions/36238510/how-to-give-priority-to-button/36298693#36298693トップボタンがタッチされた後にすべてを返す必要があります。 – meisenman