我有一個GestureDetector和許多子程式,例如TextButtons。我想在一個Button被按下時,從Gesturedetector和一個Button啟動ontap。在下面的例子中,如果我按下Button 1,輸出應該是
。Button 1 tap
手勢檢測器敲擊
我試圖改變GestureDetector的行為,但沒有任何效果。
class MyHomePage extends StatelessWidget {
MyHomePage({Key? key, required this.title}) : super(key: 關鍵)。
final String title。
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => print("GestureDetector tap"/span>)。
孩子。Scaffold(
appBar: AppBar(
標題。Text(title),
),
body: 列(
兒童。[
TextButton(
孩子。Text("Button 1")。
onPressed: () => print("Button 1 tap") 。
),
TextButton(
孩子。Text("Button 2")。
onPressed: () => print("Button 2 tap") 。
)
],
)
),
);
}
}
我可以寫一個方法并把它放在所有的onTap/onpressed中,但我認為我錯過了什么。
uj5u.com熱心網友回復:
我找到了onTertiaryTapDown的proppertie。
......在短暫的超時后,即使獲勝的手勢尚未被選中,也會呼叫這個功能。 還沒有被選中....
class MyHomePage extends StatelessWidget {
MyHomePage({Key? key, required this.title}) : super(key: 關鍵)。
final String title。
@override
Widget build(BuildContext context) {
return GestureDetector(
onTertiaryTapDown: (tapDownDetails) =>{ print("GestureDetector tap") },
孩子。Scaffold(
appBar: AppBar(
標題。Text(title),
),
body: 列(
兒童。[
TextButton(
孩子。Text("Button 1")。
onPressed: () => print("Button 1 tap") 。
),
TextButton(
孩子。Text("Button 2")。
onPressed: () => print("Button 2 tap") 。
)
],
)
),
);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/320735.html
標籤:
上一篇:<p>我做了一個有俄語字符和拉丁語字符的虛擬鍵盤。我想讓虛擬鍵盤上的每個字符鍵(.keyLetter)將俄文字符(.primary)插入文本欄位中。 此外,我想讓每個物理鍵盤的按鍵激活螢屏
