29

Today I have encountered some interesting piece of code:
In order to make a button disabled, the text of that button is assigned a grey color.
And in the click handler, there is a check if the color of the text of that button is grey, then return from it and do nothing.

That might be the ugliest hack that I had ever encountered πŸ˜†

Comments
  • 20
    I'd say this code falls into a grey area...
  • 4
    Whoever did this is a ducking genius in web-Frontend terms!
  • 4
    @010001111 yes. Except it wasn't web frontend but native iOS in Objective-C πŸ˜„
  • 5
    Oh webshiters. You do you, no matter what language you end up writing.
  • 3
    I am impressed, and horrified, all at the same time.

    @SortOfTested we have "standards" to up hold 🀷‍♂️
  • 10
    "Hey, the user clicked the button! What should I do?"
    "Well, it depends. Was the button...*gray* by any chance?"
  • 1
    what if you want to change the style of color used for disabled buttons?

    is this the type of situation that separation of concerns comes into play for?
  • 4
    @Jilano πŸ€”something like

    @hexbot #424242
  • 1
    Or @hexbot #d2d2d2
  • 1
  • 3
    I've seen some legacy code where button background color is used as a flag in code. As in if button background is green, execute x, and if yellow, execute y and so on.
Add Comment