Right mouse and on_selection

Using DataViewVirtualListCtrl and as promised if you have handlers for on_selection and on_context, the on_context is handled first. What I want is to differentiate between a left or right click in the on_selection handler. The reason is that the on_selection causes a database read, to read the details of the selected item and can reset the list. This then means that the on_context gets the wrong item due to the context switch in the underlying data.

So how can I tell that I need to reset the data if it’s a left click and leave the data alone if it’s a right click? I’m looking someplace in the event structure for the type of button pushed, but it’s not obvious to me where that is.

well, I haven’t done anything with the DataView and the docu seems to suggest that for what you expect a dive into the rederer is required
but a usual non-hotkey solution is a wx.Menu called via GetPopupMenuSelectionFromUser :thinking:

Thanks, I’ll look into that. But I have a feeling wx.Menu is too late as normally you initiate the menu from the right click. That’s what I do now and the call to on_selection is already complete. But research I will.

I’m not talking about the context menu on right click (that is untouched) !
On left click you go into selection and there you pull up a (selection) wx.Menu and you can pick what to do via …

menu

    def menu_noind(self):
        # a pop up menu
        menu = wx.Menu()
        menu.Append(1, 'update')
        menu.Append(2, 'insert')
        menu.Append(3, 'delete')
        sel = self.GetPopupMenuSelectionFromUser(menu)
        menu.Destroy()
        if sel == wx.ID_NONE:
            sel = 0
        return sel

call

                upd_ins = self.menu_noind()
                if upd_ins:    # 1 = update, 2 = insert, 3 = delete
                    row = val[0]
                    idx = self.row_idx[row]
                    entry = self.count[idx]
                    if upd_ins in (1, 3) and entry[2]:
                        App.set_error(
                            self.sb, 'Entry has been counted before')
                    else:
                        if upd_ins == 3:

Thanks that gave me the hint in the right direction. I have to treat selection differently and not automatically assume that selection implies switching of the underlying dataframe. Have to have the user choose if they want to switch or select.

Thank you.