Pregunta

I have a list view with buttons but am not able to triggered the click event for buttons in qml blackberry 10 ? Can anyone help me about this regards,

ListView {
    verticalAlignment: VerticalAlignment.Center
    horizontalAlignment: HorizontalAlignment.Center
    layout: FlowListLayout {
    }
    dataModel: mydatamodel
    listItemComponents: [
        ListItemComponent {
            type: "item"
            Container {
                layout: DockLayout {
                }

                Button {
                    id: samplebutton
                    text: "Button"
                    horizontalAlignment: HorizontalAlignment.Right
                    onClicked: {
                        //click event not fired here..
                    }
                }
                Label {
                    horizontalAlignment: HorizontalAlignment.Left
                    text: "Sample Label"
                }
                Divider {
                    horizontalAlignment: HorizontalAlignment.Fill
                }
            }
        }
    ]
    onTriggered: {
        var selectedItem = dataModel.data(indexPath);
    }
}
¿Fue útil?

Solución

I suspect it may be an issue related to something outside of the code you've pasted, but you can try the following as alternatives for the onclicked which may work better for you anway.

If neither of the below options work then you need to check your console logs for anything that might be causing it.

onTouch: {
  if (event.isUp()) {
    //do stuff here
  }
}

or

gestureHandlers: [
    gestureHandlers: [
        TapHandler {
            onTapped: {
                 //do stuff.  This is equivalent to an onClick
            }                
        },
        LongPressHandler {
            onLongPressed: {
                //do stuff when user holds down
            }            
        }        
]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top