Merge pull request #1483 from DubeySandeep/ScrollableDropdowns

Added scrollable functionality to dropdown menu
This commit is contained in:
Rachel Fenichel
2017-12-04 10:39:43 -08:00
committed by GitHub
2 changed files with 13 additions and 0 deletions

View File

@@ -505,6 +505,9 @@ Blockly.Css.CONTENT = [
'.blocklyDropdownMenu {',
'padding: 0 !important;',
/* max-height value is same as the constant
* Blockly.FieldDropdown.MAX_MENU_HEIGHT defined in field_dropdown.js. */
'max-height: 300px !important;',
'}',
/* Override the default Closure URL. */

View File

@@ -68,6 +68,12 @@ goog.inherits(Blockly.FieldDropdown, Blockly.Field);
*/
Blockly.FieldDropdown.CHECKMARK_OVERHANG = 25;
/**
* Maximum height of the dropdown menu,it's also referenced in css.js as
* part of .blocklyDropdownMenu.
*/
Blockly.FieldDropdown.MAX_MENU_HEIGHT = 300;
/**
* Android can't (in 2014) display "▾", so use "▼" instead.
*/
@@ -239,6 +245,10 @@ Blockly.FieldDropdown.prototype.positionMenu_ = function(menu) {
this.createWidget_(menu);
var menuSize = Blockly.utils.uiMenu.getSize(menu);
if (menuSize.height > Blockly.FieldDropdown.MAX_MENU_HEIGHT) {
menuSize.height = Blockly.FieldDropdown.MAX_MENU_HEIGHT;
}
if (this.sourceBlock_.RTL) {
Blockly.utils.uiMenu.adjustBBoxesForRTL(viewportBBox, anchorBBox, menuSize);
}