Dropdown
Use Glamorous dropdowns to show a contextual popup associated with a UI element on click.
This can be achieved by adding BrGlamorousWithDropdownAptitude
look to any visual component, such as Button
.
Dropdown for a button with a label
BrGlamorousComponentsDropdowns>>#buttonWithLabel <gtExample> ^ BrButton new aptitude: BrGlamorousButtonWithLabelAptitude + (BrGlamorousWithDropdownAptitude handle: [ BrButton new aptitude: BrGlamorousButtonRectangularAptitude + BrGlamorousButtonLabelAptitude; label: 'Click me' ] content: [ BlElement new background: (Color gray alpha: 0.2); size: 100 @ 100; margin: (BlInsets all: 10) ]); label: 'Click me'
Dropdown for a button with an icon
BrGlamorousComponentsDropdowns>>#buttonWithIcon <gtExample> ^ BrButton new aptitude: BrGlamorousButtonWithIconAptitude + (BrGlamorousWithDropdownAptitude handle: [ BrButton new aptitude: BrGlamorousButtonRectangularAptitude + BrGlamorousButtonIconAptitude; icon: BrGlamorousIcons menu ] content: [ BlElement new background: (Color gray alpha: 0.2); size: 100 @ 100; margin: (BlInsets all: 10) ]); icon: BrGlamorousIcons menu; label: 'Click me'
Programmatically hide a dropdown
Sometimes it is necessary to hide a dropdown due to some user action, this can be achieved by firing BrDropdownHideWish
wish:
BrGlamorousComponentsDropdowns>>#hideDropdown <gtExample> ^ BrButton new aptitude: BrGlamorousButtonWithIconAptitude + (BrGlamorousWithDropdownAptitude handle: [ BrButton new aptitude: BrGlamorousButtonRectangularAptitude + BrGlamorousButtonIconAptitude; icon: BrGlamorousIcons menu ] content: [ BrButton new aptitude: BrGlamorousButtonWithLabelAptitude; margin: (BlInsets all: 20); label: 'Close'; action: [ :aButton | aButton fireEvent: BrDropdownHideWish new ] ]); icon: BrGlamorousIcons menu; label: 'Click me'