Jump to content




Scrolling Button Menu


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

#1 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 26 February 2015 - 07:40 PM

messy, inefficient code

Everything works normally, until I try to drag the scroll bar. I will later have to change the amount added/subtracked, but for now I'd just like it to increment offset.

I'd guess it's this line that's the problem:

			if event[ 3 ] == maxx and event[ 4 ] >= math.abs( offset/(#content*5/maxy) ) and event[ 4 ] <= math.abs( offset/(#content*5/maxy) ) + (maxy / (#content*5) * maxy) + 1 then


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 26 February 2015 - 08:27 PM

Okay, everything works normally before you try to drag it, what happens after you try to drag it?

#3 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 27 February 2015 - 12:15 AM

Nothing. That's the problem.

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 27 February 2015 - 12:55 AM

So, the scroll bar appears to not do anything, but the rest of the program still works, or the scroll bar appears to do nothing and then the rest of the program becomes unresponsive? Does the problem appear when you just click the scroll bar, or does it require an attempt to drag it?

#5 Quintuple Agent

  • Members
  • 107 posts
  • LocationThis page

Posted 27 February 2015 - 12:56 AM

elseif event[ 1 ] == "mouse_drag" and barClicked then
		 offset = offset + (event[ 4 ] - lasty)
		 lastx, lasty = event[ 3 ], event[ 4 ]
end
to
elseif event[ 1 ] == "mouse_drag" then
		offset = offset - (event[ 4 ] - lasty)
		lastx, lasty = event[ 3 ], event[ 4 ]
		display( content, offset )
end
You forgot your display() function also change the offset + (event[ 4 ] - lasty) to offset - (event[ 4 ] - lasty), or else the movement will be backwards, also you might need to multiply the (event[ 4 ] - lasty) by something to scale it with the mouse movement.

Also just a note, (maxy^2 / (#content*5) ) is the same as (maxy /(#content*5) * maxy)
and (offset*maxy)/(#content*5) is the same as offset/(#content*5/maxy)
(does not matter, just looks better in my opinion)

Edit: Doing
offset = offset - (event[ 4 ] - lasty) * ( #content / 5 )
seemed to do the trick, this all worked for me
Spoiler

Edited by Quintuple Agent, 27 February 2015 - 01:03 AM.


#6 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 27 February 2015 - 01:54 AM

View PostLyqyd, on 27 February 2015 - 12:55 AM, said:

So, the scroll bar appears to not do anything, but the rest of the program still works, or the scroll bar appears to do nothing and then the rest of the program becomes unresponsive? Does the problem appear when you just click the scroll bar, or does it require an attempt to drag it?

To clarify, the program simply doesn't respond to clicking and dragging the scroll bar. Other functionality is not affected after attempting to drag the scroll bar. The scroll bar displays properly.

I suspect Quintuple Agent has fixed the issue, I will try this later as I am not able to at present.





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users