I would like to create a plugin that can operate on the currently selected item in the PCBNew window. For this purpose, I’d like to understand how a plugin would get the selected item(s) from the API.
For example, I would like to implement something that can quickly set the justification of a footprint text. Like one might with a button or hotkey in Excel or Word.
So the user would select the item, say the footprint’s Value field on the Fab layer, and run this plugin to apply FP_TEXT.SetHorizJustify() accordingly. (One would need three plugins, for left, right and center.)
I see that EDA_ITEMs (like FP_TEXT) have a IsSelected field. But I am hoping that iterating every single text of every footprint is not the way to discover which item is selected.
Is there some more direct way for the plugin to find the selected text?
I realize that implementing features like I described also runs into the problem of how the user activates the plugin conveniently, given that currently there’s no way to tie a hotkey to a plugin. However, Streamdeck. And I guess if desperate I could have Streamdeck open the item’s edit dialog, and tab its way to the Justification combo box etc.
But in general I’d like to know the plugin way to operate on the selected footprint(s), texts and so on. And maybe at some point Kicad will offer hotkeys for plugins to complete the picture.