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

Allow nil in listbox, setting text to item not in the items list. #67

Open
meruby opened this issue Aug 25, 2012 · 4 comments
Open

Allow nil in listbox, setting text to item not in the items list. #67

meruby opened this issue Aug 25, 2012 · 4 comments

Comments

@meruby
Copy link

meruby commented Aug 25, 2012

There are times when you don't want anything from selection. To do this I have to add "nil" in item lists. It works, but I think it is not a bad idea to have a option which allows user to clear selected item. You can do this with new option :entry, but user might want to just allow nil as a selected item without allowing user to type anything. Do you think it make sense?

One more thing I think we should add to listbox is if :entry is set to true, allow user to set text value which might not be in the list items.

Once again, thanks for wonderful green_shoes and making changes to it quickly.

@ashbb
Copy link
Owner

ashbb commented Aug 27, 2012

@meruby
If you overwrite Shoes::ListBox#text method like this, you can get nil when you don't select anything.

class Shoes::ListBox
  alias :_text :text
  def text
    return unless @real.active_text
    _text
  end
end

Shoes.app do
  lb = list_box items: [1, 2, 3, 4]
  button 'print' do
    p lb.text
  end
end

But in the above code, once you select one of items, you will never clear the selected item. So, IMHO, it's better to add nil in item list like this: list_box items: [1, 2, 3, 4, nil]

One more thing I think we should add to listbox is if :entry is set to true, allow user to set text value which might not be in the list items.

Ah,... what does it mean to add?
It means that we should add the user input value to the array of items?

@meruby
Copy link
Author

meruby commented Aug 27, 2012

If user has det default value to say 9 in list box, but list contains only
[1,2,3,4,5], we should allow 9 to stay in listbox text if :entry is set to
true. listbox items list will be still same [1,2,3,4,5].

Samir

On Mon, Aug 27, 2012 at 7:13 AM, ashbb notifications@github.com wrote:

@meruby https://github.com/meruby
If you overwrite Shoes::ListBox#text method like this, you can get nilwhen you don't select anything.

class Shoes::ListBox
alias :_text :text
def text
return unless @real.active_text
_text
endend
Shoes.app do
lb = list_box items: [1, 2, 3, 4]
button 'print' do
p lb.text
endend

But in the above code, once you select one of items, you will never clear
the selected item. So, IMHO, it's better to add nil in item list like this: list_box
items: [1, 2, 3, 4, nil]

One more thing I think we should add to listbox is if :entry is set to
true, allow user to set text value which might not be in the list items.

Ah,... what does it mean to add?
It means that we should add the user input value to the array of items?


Reply to this email directly or view it on GitHubhttps://github.com//issues/67#issuecomment-8052811.

  • Samir Patel

@ashbb
Copy link
Owner

ashbb commented Aug 28, 2012

You mean the following snippet should work well. Right?

Shoes.app do
  lb = list_box items: [1, 2, 3, 4], entry: true, choose: 9
  button 'print' do
    p lb.text
  end
end

If so, I'll be able to update Green Shoes.
But if there is still my misunderstanging, please let me know.

@meruby
Copy link
Author

meruby commented Aug 28, 2012

Yes, this should work well. Thanks for accepting my suggestion.

Samir

On Tue, Aug 28, 2012 at 9:52 AM, ashbb notifications@github.com wrote:

You mean the following snippet should work well. Right?

Shoes.app do
lb = list_box items: [1, 2, 3, 4], entry: true, choose: 9

button 'print' do
p lb.text
endend

If so, I'll be able to update Green Shoes.
But if there is still my misunderstanging, please let me know.


Reply to this email directly or view it on GitHubhttps://github.com//issues/67#issuecomment-8092081.

  • Samir Patel

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