[M]ister Posted July 3, 2014 Share Posted July 3, 2014 Hello I am using this dxgui: https://drive.google.com/folderview?id= ... sp=sharing. However when I want to make the list invisible the scrollbar continues, could someone help me? Image: dxList.lua File: --[[ /*************************************************************************************************************** * * PROJECT: dxGUI * LICENSE: See LICENSE in the top level directory * FILE: components/dxList.lua * PURPOSE: All listbox functions. * DEVELOPERS: Skyline * * dxGUI is available from [url=https://community.multitheftauto.com/index.php?p=resources&s=details&id=4871]https://community.multitheftauto.com/index.php?p= ... ls&id=4871[/url] * ****************************************************************************************************************/ ]] -- // Initializing function dxCreateList(x,y,width,height,title,parent,color,font,theme) if not x or not y or not width or not height then outputDebugString("dxCreateList gets wrong parameters (x,y,width,height[,title=\"\",parent=dxGetRootPane(),color=black,font=default,theme=dxGetDefaultTheme()])") return end if not title then title = "" end if not color then color = tocolor(0,0,0,255) end if not font then font = "default" end if not parent then parent = dxGetRootPane() end if not theme then theme = dxGetElementTheme(parent) end if type(theme) == "string" then theme = dxGetTheme(theme) end if not theme then outputDebugString("dxCreateList didn't find the main theme.") return false end local list = createElement("SDT_GUI_List") setElementParent(list, parent) setElementData(list,"SDT_Resource",sourceResource) setElementData(list,"SDT_X",x) setElementData(list,"SDT_Y",y) setElementData(list,"SDT_Width",width) setElementData(list,"SDT_Height",height) setElementData(list,"SDT_Text",title) setElementData(list,"SDT_Title:show",false) setElementData(list,"SDT_Theme",theme) setElementData(list,"SDT_Color",color) setElementData(list,"SDT_Font",font) setElementData(list,"SDT_Visible",true) setElementData(list,"SDT_Hover",false) setElementData(list,"SDT_Parent",parent) setElementData(list,"SDT_Container",false) setElementData(list,"SDT_SelectedItem",nil) setElementData(list,"SDT_ScrollbarVert",false) setElementData(list,"SDT_ScrollbarHorz",false) setElementData(list,"SDT_Clicked",false) setElementData(list,"SDT_PostGUI",false) setElementData(list,"SDT_RenderFunction","dxListRender") setElementData(list,"SDT_ZOrder",getElementData(parent,"SDT_ZIndex")+1) setElementData(parent,"SDT_ZIndex",getElementData(parent,"SDT_ZIndex")+1) addEventHandler("onClientDXClick",list,__list,false) addEventHandler("onClientDXDoubleClick",list,list__,false) return list end -- // Functions function dxListClear(dxElement) if not dxElement or getElementType(dxElement) ~= "SDT_GUI_List" then outputDebugString("dxListClear gets wrong parameters.(dxList)") return end for _,v in ipairs(getElementChildren(dxElement)) do destroyElement(v) end end function dxListGetItems(dxElement) if not dxElement or getElementType(dxElement) ~= "SDT_GUI_List" then outputDebugString("dxListClear gets wrong parameters.(dxList)") return end return getElementChildren(dxElement) end function dxListGetItemCount(dxElement) if not dxElement or getElementType(dxElement) ~= "SDT_GUI_List" then outputDebugString("dxListClear gets wrong parameters.(dxList)") return end return #getElementChildren(dxElement) end function dxListGetSelectedItem(dxElement) if not dxElement or getElementType(dxElement) ~= "SDT_GUI_List" then outputDebugString("dxListGetSelectedItem gets wrong parameters.(dxList)") return end return getElementData(dxElement,"SDT_SelectedItem") end function dxListSetSelectedItem(dxElement,item) if not dxElement or getElementType(dxElement) ~= "SDT_GUI_List" or not item or getElementType(item)~="SDT_GUI_ListItem" then outputDebugString("dxListSetSelectedItem gets wrong parameters.(dxList,dxListItem)") return end setElementData(dxElement,"SDT_SelectedItem",item) for _,w in ipairs(getElementChildren(dxElement)) do setElementData(w,"SDT_Clicked",false) end setElementData(item,"SDT_Clicked",true) end function dxListRemoveRow(dxElement) if not dxElement or getElementType(dxElement) ~= "SDT_GUI_ListItem" then outputDebugString("dxListRemoveRow gets wrong parameters.(dxListItem)") return end destroyElement(dxElement) end function dxListAddRow(dxElement,text,color,font,colorcoded) if not dxElement or getElementType(dxElement) ~= "SDT_GUI_List" then outputDebugString("dxListAddRow gets wrong parameters.(dxList[,text=\"\",color=black,font=default,colorcoded=false])") return end if not text then text = "" end if not color then color = tocolor(0,0,0,255) end if not font then font = "default" end if colorcoded == nil then colorcoded = false end local item = createElement("SDT_GUI_ListItem") setElementParent(item,dxElement) dxSetText(item,text) setElementData(item,"SDT_Color",color) setElementData(item,"SDT_Font",font) setElementData(item,"SDT_Clicked",false) setElementData(item,"SDT_Shown",false) dxSetColorCoded(item,colorcoded) --dxListSetSelectedItem(dxElement,item); return item end function dxListSetTitleVisible(dxElement,titleShow) if not dxElement or getElementType(dxElement) ~= "SDT_GUI_List" or titleShow==nil then outputDebugString("dxListSetTitleShow gets wrong parameters.(dxList,titleShow)") return end setElementData(dxElement,"SDT_Title:show",titleShow) end function dxListGetTitleVisible(dxElement) if not dxElement or getElementType(dxElement) ~= "SDT_GUI_List" then outputDebugString("dxListGetTitleShow gets wrong parameters.(dxList)") return end return getElementData(dxElement,"SDT_Title:show") end -- // Events function __list(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld) local list = source local parentX = getElementData(getElementParent(list),"SDT_X") local parentY = getElementData(getElementParent(list),"SDT_Y") local x,y = parentX+getElementData(list,"SDT_X"),parentY+getElementData(list,"SDT_Y") local width = getElementData(list,"SDT_Width") local height = getElementData(list,"SDT_Height") local cTheme = dxGetElementTheme(list) local tShow = getElementData(list,"SDT_Title:show") local titleHeight = getElementData(cTheme,"ListBoxTitle:Height") local coh = height local cpyyy = y local scrollbarVert = getElementData(list,"SDT_ScrollbarVert") if (scrollbarVert) then width = width-20 end if (tShow) then if (intersect(x,y,x+width,y+titleHeight,absoluteX,absoluteY)) then return; end coh = coh-titleHeight cpyyy = cpyyy+titleHeight end local itemHeight = 23 local itemMultiplyHeight = 23 local itemMultiply = 0.9 local itemSorter = 0 if ( scrollbarVert ) then itemSorter = (dxScrollBarGetScroll(scrollbarVert)/100)*dxListGetItemCount(list)*itemMultiply*itemMultiplyHeight end itemSorter = itemSorter/2 local itemClicked = 0 for id,item in ipairs(getElementChildren(list)) do setElementData(item,"SDT_Clicked",false) if ( id*itemMultiply*itemMultiplyHeight - itemSorter <= coh+itemHeight ) and (id*itemMultiply*itemMultiplyHeight - itemSorter >=0) and itemClicked == 0 then local itemMax = math.max((id-1)*itemMultiply*itemMultiplyHeight-itemSorter,0) local itemShow = (cpyyy+coh)-(cpyyy+itemMax-23) itemShow = math.min(itemShow,itemHeight)-3 if (intersect(x+1,cpyyy+itemMax,x+1+width-2,cpyyy+itemMax+itemShow,absoluteX,absoluteY)) then setElementData(item,"SDT_Clicked",true) setElementData(list,"SDT_SelectedItem",item) triggerEvent("onClientDXClick",item,button,state,absoluteX,absoluteY) end end end end function list__(button, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld) local list = source local parentX = getElementData(getElementParent(list),"SDT_X") local parentY = getElementData(getElementParent(list),"SDT_Y") local x,y = parentX+getElementData(list,"SDT_X"),parentY+getElementData(list,"SDT_Y") local width = getElementData(list,"SDT_Width") local height = getElementData(list,"SDT_Height") local cTheme = dxGetElementTheme(list) local tShow = getElementData(list,"SDT_Title:show") local titleHeight = getElementData(cTheme,"ListBoxTitle:Height") local coh = height local cpyyy = y local scrollbarVert = getElementData(list,"SDT_ScrollbarVert") if (scrollbarVert) then width = width Link to comment
_DrXenon Posted July 3, 2014 Share Posted July 3, 2014 I couldn't see the whole code.. but you sure that the scrollbar is created as part of list? Link to comment
[M]ister Posted July 3, 2014 Author Share Posted July 3, 2014 Yes. On line 358 of file dxList.lua: scrollbarVert = dxCreateScrollBar(cx+cw-22,cy,20,choc,getElementParent(component),"Vertical",0,200,cTheme) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now