HeinrichApfelmus / threepenny-gui

GUI framework that uses the web browser as a display.
https://heinrichapfelmus.github.io/threepenny-gui/
Other
439 stars 77 forks source link

Experimental custom widgets and element linking #104

Open archaephyrryx opened 9 years ago

archaephyrryx commented 9 years ago

I have been working on writing a Web UI/GUI for a personal project in Haskell, and I found your library to be the most satisfying and intuitive, even if I had to dig a lot and experiment (which I found useful). As part of this project, I wrote several widgets, which I would be interested in your opinions on. I am not a seasoned programmer (though I have been programming for some time), and this is code I am writing for fun, so my naming conventions might seem a bit odd and informal (though you might get a laugh out of some of them). You can find all the widgets I have written (and will write) here.

I don't know whether you are the right person to ask about this (it seems a general question, but still highly specific to your library, so I figure you would be the best person to ask), but I have had a bit of trouble implementing a multiple-enabled select input with an associated clear-button; while I have managed to get the FRP right, I still haven't found a good way to physically clear the selection in-browser when the button is clicked. I have found some jQuery code that works in the web console when I am running my GUI, but I don't know a good way of associating a click-event of one element to running an FFI function on another. Do you have any suggestions for me?

Thanks for creating this wonderful library, which I first found a bit opaque but now find clearer than many other UI libraries.

archaephyrryx commented 9 years ago

Just follow-up on the problem I was having; this is probably the right way according to the philosophy of your code, but I handled the display matter with an event handler in the main GUI setup, as on UI.click clearButton $ \_ -> element selectionBox # set clearSels () (clearSels is a writeAttr that does the jQuery selection clearing). I would still be interested in hearing your feedback, though. I am leaving this issue open for now, just so that you can decide what its proper status should be. Thanks again for creating this incredible library. If you are interested, I would be willing to contribute any of the widgets and macros I end up writing to the library.

HeinrichApfelmus commented 9 years ago

Glad you like it! Sorry for the long delay, I am currently rather swamped with work.

The way you solved it sounds good to me. One thing I found very useful, though, and which I employed in the CRUD example, is to make the selection part of the model. In other words, it should be possible to pass a Behavior t [Int] on widget creation where Int is a list of indices; or something along these lines. The idea is that your program logic determines the behavior of the selection, and both the multiselect widget and the clear button may make suggestions ("Tidings") on how to change it. It's not enough to leave it just to the multiselect widget alone. But in any case, my current philosophy on the widget stuff is "whatever works right now".