I found a solution. As it turns out, there is a default command called onSelect that works for things like this. I'm still not sure why getSelectedId() didn't work, but this works great!
function PerkGui::onSelect(%line, %name, %cost, %section, %status)
{
//stuff to do
}