2

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);
    }
}
nonesuchnick
  • 627
  • 4
  • 17
SelvaRaman
  • 218
  • 2
  • 15

1 Answers1

3

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
            }            
        }        
]
hyarion
  • 2,251
  • 2
  • 17
  • 28
  • 1
    Hi,the onTouch and gestureHandlers is not working when i click the button(need to go next qml page),can u send some button click examples Thanks – Vendetta Feb 25 '13 at 07:40