The action you're talking about is "Select" in JASS. Try searching it under the functionlist. EnumSelectUnits, IsUnitSelected, all of those are good examples.
It does not work on destructibles though, which is not how inventory systems (Like TKoK's) work anyways. They might use a zoom in on units with single plane models that're wrapped in a button skin to make the unit look like a button. Really they're just a bunch of units placed around an area.
It's actually very complicated and takes some major planning out. Smaller systems may use abilities and ability buttons.
Whatever your route, good luck.