fix crashes when the selected element is NULL (via lua), add gfx.getHexColor (inverse of gfx.getColors)