Did you try to do a layout grid and put in column the text field and in the other the widget, i think u need to put outside of the textbox the icon, because when the text box is active it disable the choice of clicking inside od it
Would love to see Mendix make this standard funtionality of text-boxes for which its property '’General → Show as password” is true.
Also my idea would be to use the font-awesome variant of the image: fa-eye-slash and fa-eye.
And answering you question: an option is to set the icon to the right of the textbox, give it a border for top, right and bottom, no left margin or padding. And the textbox no border, margin and padding on the right. This will make it look one object only but you will have no overlap at all.