Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown menu without dropdown? #172

Open
izaid opened this issue Aug 2, 2016 · 2 comments
Open

Dropdown menu without dropdown? #172

izaid opened this issue Aug 2, 2016 · 2 comments

Comments

@izaid
Copy link
Contributor

izaid commented Aug 2, 2016

This is a great library, thanks for writing it!

I have a really simple question. I'd basically like a selection widget -- a bunch of vertical items with a scrollbar if there are too many. This is exactly what I get with the dropdown menu, except I don't want to be dropdown -- I want it always there.

Is this possible? If so, how?

@shashi
Copy link
Member

shashi commented Aug 10, 2016

You can make in Escher:

function select_from(selected, items, current_item)
     map(items) do t
        item = (t == selected ? fillcolor("#9ba", pad(0.5em, t)) : pad(0.5em, t))
        subscribe(current_item, intent(_->t, clickable(item)))
    end |> vbox |> clip(auto) |> size(10em, 22em)
end

Arguments are selected the item currently selected, items a list of items (strings) to show, and finally current_item is a signal that gets updated when the user clicks on an item.

You can make this fancy: make it possible to select multiple items, use checkboxes against each item etc...

@izaid
Copy link
Contributor Author

izaid commented Sep 13, 2016

@shashi Thanks! This does create exactly the dropdown select I'm looking for, but I'm finding the clicking doesn't change the menu (tried in Firefox and Chrome). The initial selection stays selected all the time. Any thoughts?

I assumed the right way to use this (which may be wrong), would be to something like:

mysig = Signal(0)
select = select_from(inital_item, items, mysig)

map(mysig) do current
    hbox(..., select)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants