Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you have an object-oriented language (or near enough) with usable function types you can still emulate "traditional" GUI things if you really want to. Behold:

  class ButtonObj
    method call():
      if(button(label, loc) callback()

    member Rect loc
    member String label
    member Func callback

  list displayList = [];
  displayList.add(ButtonObj("label", 100, 100, buttonAction))

  Func eventLoop():
    for i in displayList:
      i.call()


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: