Author Topic: UIScrollBar  (Read 37349 times)

coolaneasy

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: UIScrollBar
« Reply #15 on: July 11, 2014, 02:16:24 PM »
Seems like value is always being set to 0 in OnDragBackground callback. Moving the value in UIScrollBar seems to be moving the thumb just fine.
ps. I don't have a foreground. Could that be causing the problem? Doing quick test.

stilghar

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: UIScrollBar
« Reply #16 on: September 20, 2014, 06:23:11 AM »
Hi, is it possible to control a scrollbar with keyboard and gamepad? The full UI that we are doing is controlled with keyboard and gamepad (just using UI Key Navigation), is there something similar to control a scrollbar?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollBar
« Reply #17 on: September 20, 2014, 09:37:24 AM »
Sure, scroll bars and sliders can both be controlled with a keyboard/controller. Check the Controller Input menu example.

stilghar

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: UIScrollBar
« Reply #18 on: September 21, 2014, 03:43:00 AM »
Thanks, it now works. Strangely enough when I click up in the keyboard when the Vertical scrollbar is selected it actually moves down and the other way around (hitting down goes up). Any ideas of what could this be?

EDIT: I just solved it, silly me. Changing direction to bottomToTop did it.
EDIT2: Turns out it is NOT SOLVED, changing the direction to bottomToTop allows me to control it with keyboard as I want but I would like the scrollbar to be topToBottom.
« Last Edit: September 21, 2014, 04:13:10 AM by stilghar »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollBar
« Reply #19 on: September 21, 2014, 09:26:07 AM »
That seems like a bug in UISlider. Change its OnKey function to the following and it should work:
  1.         /// <summary>
  2.         /// Watch for key events and adjust the value accordingly.
  3.         /// </summary>
  4.  
  5.         protected void OnKey (KeyCode key)
  6.         {
  7.                 if (enabled)
  8.                 {
  9.                         float step = (numberOfSteps > 1f) ? 1f / (numberOfSteps - 1) : 0.125f;
  10.  
  11.                         switch (mFill)
  12.                         {
  13.                                 case FillDirection.LeftToRight:
  14.                                 {
  15.                                         if (key == KeyCode.LeftArrow) value = mValue - step;
  16.                                         else if (key == KeyCode.RightArrow) value = mValue + step;
  17.                                 }
  18.                                 break;
  19.  
  20.                                 case FillDirection.RightToLeft:
  21.                                 {
  22.                                         if (key == KeyCode.LeftArrow) value = mValue + step;
  23.                                         else if (key == KeyCode.RightArrow) value = mValue - step;
  24.                                 }
  25.                                 break;
  26.  
  27.                                 case FillDirection.BottomToTop:
  28.                                 {
  29.                                         if (key == KeyCode.DownArrow) value = mValue - step;
  30.                                         else if (key == KeyCode.UpArrow) value = mValue + step;
  31.                                 }
  32.                                 break;
  33.  
  34.                                 case FillDirection.TopToBottom:
  35.                                 {
  36.                                         if (key == KeyCode.DownArrow) value = mValue + step;
  37.                                         else if (key == KeyCode.UpArrow) value = mValue - step;
  38.                                 }
  39.                                 break;
  40.                         }
  41.                 }
  42.         }

thebroll

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: UIScrollBar
« Reply #20 on: November 07, 2014, 03:12:26 PM »
How might I make a UI slider that starts from the center and grows out? I have found a old tutorial on this but that example seems to be deprecated.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollBar
« Reply #21 on: November 07, 2014, 04:14:32 PM »
Use a scroll bar with its value set to 0.5. Instead of adjusting the value, adjust the scroll bar's size.

The-Arrival

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: UIScrollBar
« Reply #22 on: February 19, 2016, 04:01:27 AM »
Is it possible to subscribe to the ValueChange a FloatEvent, passing around the changed Value?

I checked your Slider example and the SetCurrentPercent method pulls the value from the slider itself.

i also tried thsi, but for sure it allways passes the same value saved on subscription

  1. EventDelegate del = new EventDelegate(ui, "SpeedChange");
  2.         del.parameters[0].value = scrollBar.value;
  3.         EventDelegate.Set(scrollBar.onChange, del);
  4.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollBar
« Reply #23 on: February 22, 2016, 07:22:07 PM »
There is no need. Check UIProgressBar.current.value.