Implemented text centering

Redesigned event handling