Your browser does not support JavaScript or its disabled!
Please turn it on, or be aware that some features on this website will not work correctly.
1.7K
Combobox Parent Width #92
This allows you to set the width of a comboox to match the parent size.
This then lets you set the combo box for all the configs in the bot to have a scroll bar and width match the parent to see longer names
File: uicombobox.lua | 374b | 13 lines.
 --[[
  Script made by Lee (Discord: l33_) - www.trainorcreations.com
  If you want to support my work, feel free to donate at https://trainorcreations.com/donate
  PS. Stop ripping off my work and selling it as your own.
 ]]--
function UIComboBox.create()
  local combobox = UIComboBox.internalCreate()
  combobox:setFocusable(false)
  combobox.options = {}
  combobox.currentIndex = -1
  combobox.mouseScroll = true
  combobox.menuScroll = false
  combobox.menuHeight = 100
  combobox.menuScrollStep = 0
+ combobox.parentWidth = false
+ combobox.removeMargin = false
  return combobox
end
+ add | - remove
File: uicombobox.lua | 0.99kb | 27 lines.
 --[[
  Script made by Lee (Discord: l33_) - www.trainorcreations.com
  If you want to support my work, feel free to donate at https://trainorcreations.com/donate
  PS. Stop ripping off my work and selling it as your own.
 ]]--
function UIComboBox:onMousePress(mousePos, mouseButton)
  local menu
  if self.menuScroll then
    menu = g_ui.createWidget(self:getStyleName() .. 'PopupScrollMenu')
    menu:setHeight(self.menuHeight)
    if self.menuScrollStep > 0 then
      menu:setScrollbarStep(self.menuScrollStep)
    end
  else
    menu = g_ui.createWidget(self:getStyleName() .. 'PopupMenu')
  end
  menu:setId(self:getId() .. 'PopupMenu')
  for i,v in ipairs(self.options) do
    menu:addOption(v.text, function() self:setCurrentOption(v.text) end)
  end
+ if self.parentWidth and self:getParent() then
+    local par = self:getParent()
+    menu:setWidth(par:getWidth() - (self.removeMargin and (par:getMarginLeft() - par:getMarginRight()) or 4))
+  else
+    menu:setWidth(self:getWidth())
+ end
- menu:setWidth(self:getWidth())
  menu:display({ x = self:getX(), y = self:getY() + 2 + self:getHeight() })
  connect(menu, { onDestroy = function() self:setOn(false) end })
  self:setOn(true)
  return true
end
+ add | - remove
File: bot.otui | 371b | 15 lines.
 MiniWindowContents
    ComboBox
      id: config
+     &menuScroll: true
+     &menuHeight: 450
+     &menuScrollStep: 100
+     &parentWidth: true
+     &removeMargin: true
      anchors.top: parent.top
      anchors.left: parent.left
      anchors.right: parent.right
      margin-top: 2
      margin-left: 2
      margin-right: 75
      text-offset: 3 0
+ add | - remove
File: config.otui | 217b | 10 lines.
  ComboBox
    id: list
    anchors.top: parent.top
    anchors.left: parent.left
    text-offset: 3 0
    width: 130
+   &menuScroll: true
+   &menuHeight: 450
+   &menuScrollStep: 100
+   &parentWidth: true
+ add | - remove

25 Apr 2022
Ads