I'm writing a network description for a a listbox logic.
It's really simple: I have a behavior for the (Maybe
) current selected item, and I want it so that whenever the user adds a new item to the list, the current selected item will select the just-created value.
It's also possible for the user to remove items from the list, and cause various of other changes, so I have to know when a new item is created; I can't just select the last item on every change.
I don't really have any code to show for it because all my speculations on what to do can't even be written with the API*, but I have the context of Frameworks t
and (simplified):
bDb :: Behavior t [Entry] -- Created with accumB.
bSelected :: Behavior t (Maybe Entry) -- Created with accumB.
eAddEntry :: Event t () -- User clicked an add button. Created with fromAddHandler.
* Well, I did think about using eAddEntry
to select the last entry, but that's so bad and even if it will work it's just a race between the adding of new item and the selecting of it.
How can I go about it?