What plugins would you like to see?

It is possible to some extent, just you would have to play some tricks. Such as when the selection tool is picked. You can either set a timer to check for selection, filter out the mouse release event, or do your own selection overlay.

A simpler way though is that a selection mask is created when you do a selection. So monitor the layer list events and when you see a selection mask being created, you know there is a selection

Edit: Simple example:

from krita import *
from PyQt5 import QtWidgets

qwin = Krita.instance().activeWindow().qwindow()
layerBox = qwin.findChild(QtWidgets.QDockWidget, "KisLayerBox")
layerList = layerBox.findChild(QtWidgets.QTreeView,"listLayers")

def layerChange():
    doc = Krita.instance().activeDocument()
    if doc.selection() is not None:
        print ("SELECTION!")
    else:
        print ("NO SELECTION")


layerList.model().sourceModel().dataChanged.connect(layerChange)
layerList.model().sourceModel().modelReset.connect(layerChange)
layerList.model().sourceModel().rowsRemoved.connect(layerChange)
1 Like