Jump to content




Scrolling the contents of a table


  • You cannot reply to this topic
6 replies to this topic

#1 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 14 March 2013 - 10:44 AM

I had just looked at the wiki and noticed the event; mouse_scroll. I sat and thought, now I how could I capture a scrollStroke and move a printed table on the screen accordingly? I'm fairly new to this event and would like to know how it works. Out of all of the events, this one caught my eye the most (Seeing as i've never used it ^_^) Any help is appreciated.

If it helps, I am trying to print shell.programs() then scroll the text up or down according to the stroke, and no, I do not want to use term.scroll().

#2 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 14 March 2013 - 11:02 AM

Load all lines you want to display in the future into a table. If it's size is larger then the terminal's height, that's not a problem. Set up an offset variable. Then change offset when a "mouse_scroll" event occurs. Ehh, it's easier inside code tags...

EDIT: Removed code tags (formatting killed code...)
http://pastebin.com/EC7MEMKi (not tested, should work though)

EDIT2: You could've asked me on Skype...

#3 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 14 March 2013 - 11:38 AM

Yeah, I figured I would have to use an offset variable.

My Skype account was acting up. I just called their support center and they got everything straightened(<--- lol did I spell that right?) out.

#4 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 15 March 2013 - 04:25 AM

Have you ever actually tried to scroll? Because the first time it calles redraw is when you scroll down...
Should call redraw right after declaring it... Oh! And figured! math.max() instead of math.min()

Fixed code on pastedbin, same url...

#5 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 15 March 2013 - 07:54 AM

Ah, I should have seen that. I also did try to scroll ;) Thanks again ^_^

#6 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 15 March 2013 - 08:43 AM

NP - BTW a "mouse_scroll" returns direction and coordinates, eg,
local event, p1, p2, p3 = os.pullEvent("mouse_scroll")

p1 is now 1 or -1 (direction) and p2 and p3 are the X and the Y coordinates of the mouse.

#7 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 15 March 2013 - 08:56 AM

View PostLBPHacker, on 15 March 2013 - 08:43 AM, said:

NP - BTW a "mouse_scroll" returns direction and coordinates, eg,
local event, p1, p2, p3 = os.pullEvent("mouse_scroll")

p1 is now 1 or -1 (direction) and p2 and p3 are the X and the Y coordinates of the mouse.
Oh, hmm. Interesting, well thanks for the tip (Mouse scroll expert over here ^_^)

When was I a Pro Coder? When did people start pressing my green vote button? Why do I have so many friends? God I need to pay attention moar.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users