Schlammy Posted May 16, 2013 Share Posted May 16, 2013 Hey Guys, I made a simple GUI with an Gridlist. The Gridlist has just one Coloumn. With a commandhandler i add some rows in this coloumn. This works fine but i want to scoll automaticly to the last row... I tested the guiGridListSetHorizontalScrollPosition and the guiGridListSetVerticalScrollPosition but it wont work... I got the last Index by counting all rows with GuiGridListGetRowCount. Pleas help A Example would be nice Link to comment
FuriouZ Posted May 16, 2013 Share Posted May 16, 2013 You need to add here some part of your code,then scripters can help you. Link to comment
Schlammy Posted May 16, 2013 Author Share Posted May 16, 2013 Okey when i`m at home ill post my problem script but i think my description of the problem must be enough to know what the problem is or not? Link to comment
csiguusz Posted May 16, 2013 Share Posted May 16, 2013 Today I tried to use the guiGridListSetVerticalScrollPosition function, but it doesn't seem to be working. The scroll position can be set between 0 and 100, but the function is bugged or what... so it sets the position wrong. Link to comment
Schlammy Posted May 17, 2013 Author Share Posted May 17, 2013 function addText(List, column, text) local row = guiGridListAddRow ( List ) guiGridListSetItemText ( List, row, column, text, false, false ) local rowCount = guiGridListGetRowCount (List) guiGridListSetHorizontalScrollPosition( List, rowCount ) end function createList () local List = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local column = guiGridListAddColumn( List, "Infos", 0.85 ) if ( column ) then addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") end end just a sample of my problem Link to comment
Tete omar Posted May 17, 2013 Share Posted May 17, 2013 Today I tried to use the guiGridListSetVerticalScrollPosition function, but it doesn't seem to be working.The scroll position can be set between 0 and 100, but the function is bugged or what... so it sets the position wrong. i've got that problem before and i've fixed it by just using a timer with 50 ms for every guiGridListSetVerticalScrollPosition execution like this: setTimer(guiGridListSetVerticalScrollPosition, 50, 1, gridlist, 100) function addText(List, column, text) local row = guiGridListAddRow ( List ) guiGridListSetItemText ( List, row, column, text, false, false ) local rowCount = guiGridListGetRowCount (List) guiGridListSetHorizontalScrollPosition( List, rowCount ) end function createList () local List = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local column = guiGridListAddColumn( List, "Infos", 0.85 ) if ( column ) then addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") end end just a sample of my problem Here you go function addText(List, column, text) local row = guiGridListAddRow ( List ) guiGridListSetItemText ( List, row, column, text, false, false ) local rowCount = guiGridListGetRowCount (List) setTimer ( guiGridListSetHorizontalScrollPosition, 50, 1, List, 100 ) end function createList () local List = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) local column = guiGridListAddColumn( List, "Infos", 0.85 ) if ( column ) then addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") addText(List, column, "Test") end end Link to comment
Schlammy Posted May 17, 2013 Author Share Posted May 17, 2013 Okey i'll test it as soon as possible Link to comment
csiguusz Posted May 17, 2013 Share Posted May 17, 2013 @Tete omar: Yes, with the timer it should work ( It worked for me with onClientRender ) because it sets the correct position but then for some reason it jumps back. Link to comment
Schlammy Posted May 17, 2013 Author Share Posted May 17, 2013 local messageBoxVisible = true newMessageBoxGui = { gridlist = {}, window = {} } function toggleNewWindowVisible() if (messageBoxVisible == true) then guiSetVisible(newMessageBoxGui.window[1], false) messageBoxVisible = false else guiSetVisible(newMessageBoxGui.window[1], true) messageBoxVisible = true end end addEventHandler("onClientResourceStart", resourceRoot, function() newMessageBoxGui.window[1] = guiCreateWindow(0.33, 0.00, 0.33, 0.15, "", true) guiWindowSetSizable(newMessageBoxGui.window[1], false) guiSetAlpha(newMessageBoxGui.window[1], 0.59) newMessageBoxGui.gridlist[1] = guiCreateGridList(0.03, 0.17, 0.94, 0.76, true, newMessageBoxGui.window[1]) column = guiGridListAddColumn( newMessageBoxGui.gridlist[1], "", 0.85 ) if ( column ) then row = guiGridListAddRow ( newMessageBoxGui.gridlist[1] ) guiGridListSetItemText ( newMessageBoxGui.gridlist[1], row, column, "Willkommen auf ATV - Reallife", false, false ) end guiSetVisible(newMessageBoxGui.window[1], true) addNewMessage("LOL") addNewMessage("hallo") addNewMessage("LOL") addNewMessage("LOL") addNewMessage("ROFL") addNewMessage("LOL") addNewMessage("hallo") addNewMessage("LOL") addNewMessage("LOL") addNewMessage("ROFL") addNewMessage("LOL") addNewMessage("hallo") addNewMessage("LOL") addNewMessage("LOL") addNewMessage("ROFL") bindKey("o", "down", toggleNewWindowVisible) end ) function addNewMessage(message) local row = guiGridListAddRow ( newMessageBoxGui.gridlist[1] ) guiGridListSetItemText ( newMessageBoxGui.gridlist[1], row, column, message, false, false ) local rowCount = guiGridListGetRowCount ( newMessageBoxGui.gridlist[1] ) setTimer ( guiGridListSetHorizontalScrollPosition, 50, 1, newMessageBoxGui.gridlist[1], 100 ) end Don`t work ... Link to comment
Castillo Posted May 18, 2013 Share Posted May 18, 2013 The problem is that you are setting the HORIZONTAL position, not the VERTICAL position. local messageBoxVisible = true newMessageBoxGui = { gridlist = {}, window = {} } function toggleNewWindowVisible() if (messageBoxVisible == true) then guiSetVisible(newMessageBoxGui.window[1], false) messageBoxVisible = false else guiSetVisible(newMessageBoxGui.window[1], true) messageBoxVisible = true end end addEventHandler("onClientResourceStart", resourceRoot, function() newMessageBoxGui.window[1] = guiCreateWindow(0.33, 0.00, 0.33, 0.15, "", true) guiWindowSetSizable(newMessageBoxGui.window[1], false) guiSetAlpha(newMessageBoxGui.window[1], 0.59) newMessageBoxGui.gridlist[1] = guiCreateGridList(0.03, 0.17, 0.94, 0.76, true, newMessageBoxGui.window[1]) column = guiGridListAddColumn( newMessageBoxGui.gridlist[1], "", 0.85 ) if ( column ) then row = guiGridListAddRow ( newMessageBoxGui.gridlist[1] ) guiGridListSetItemText ( newMessageBoxGui.gridlist[1], row, column, "Willkommen auf ATV - Reallife", false, false ) end guiSetVisible(newMessageBoxGui.window[1], true) addNewMessage("LOL") addNewMessage("hallo") addNewMessage("LOL") addNewMessage("LOL") addNewMessage("ROFL") addNewMessage("LOL") addNewMessage("hallo") addNewMessage("LOL") addNewMessage("LOL") addNewMessage("ROFL") addNewMessage("LOL") addNewMessage("hallo") addNewMessage("LOL") addNewMessage("LOL") addNewMessage("ROFL") bindKey("o", "down", toggleNewWindowVisible) end ) function addNewMessage(message) local row = guiGridListAddRow ( newMessageBoxGui.gridlist[1] ) guiGridListSetItemText ( newMessageBoxGui.gridlist[1], row, column, message, false, false ) local rowCount = guiGridListGetRowCount ( newMessageBoxGui.gridlist[1] ) setTimer ( guiGridListSetVerticalScrollPosition, 50, 1, newMessageBoxGui.gridlist[1], 100 ) end Link to comment
Schlammy Posted May 21, 2013 Author Share Posted May 21, 2013 Ok I`ll test it as soon as possbile Link to comment
Castillo Posted May 21, 2013 Share Posted May 21, 2013 I've tested it before posting it and it worked fine. 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