Author Topic: UIPopup List Offcenter and Always First Selection  (Read 2209 times)

Yukichu

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 8
  • Posts: 101
    • View Profile
UIPopup List Offcenter and Always First Selection
« on: May 31, 2014, 10:47:25 PM »
Made a UIPopupList, and I populate it dynamically depending on what's happening.  Figured it out.

However, two things I ended up modifying and thought would be nice...

The default drop-down list for selecting which item, options for first, or last, would be great, as my list is empty when it's created. My hacky fix was to just make the first one highlighted always.  It works, but an option for first/last would be great.

Second thing was the popup list is always to right of the mouse when clicked.  I didn't really want to use an anchor and not even sure it'd work since the popup list is appearing all over the screen at different times; however, perhaps a value for 'offset' of the mouse click?  Stuff on the far right of the screen gets cut off if my text is too long, so I just offset the bounds by -20X early on.

t.localPosition = new Vector3(bounds.min.x - 20, bounds.min.y, bounds.min.z);

An actual offset value would be awesome, because you could change it via code depending on the max length of a string in the popup, etc. 

Nothing major, but these would be helpful.  Thanks.

Yukichu

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 8
  • Posts: 101
    • View Profile
Re: UIPopup List Offcenter and Always First Selection
« Reply #1 on: June 18, 2014, 11:39:25 AM »
Never saw a reply to this, so I thought I'd bring it up again since the last update I did I had to figure out what I changed in UIPopupList.cs and reproduce it again.  This time I saved my changes somewhere to remember so I don't have to worry about it as much; however, these two options might be nice.

First, last, only bump to this.  If it never goes in, well, that's okay.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopup List Offcenter and Always First Selection
« Reply #2 on: June 18, 2014, 04:39:24 PM »
I don't quite understand what you mean by pop-up list appearing to the right of the mouse. Pop-up list appears either below or above the pop-up control.

The part about selecting which item is also odd to me -- what do you mean by that? There is no option to select "first" or "last". You select actual items. If you want the first item, then select just that. After populating your popup list in code, set popupList.value = popupList.items[0], for example.

Yukichu

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 8
  • Posts: 101
    • View Profile
Re: UIPopup List Offcenter and Always First Selection
« Reply #3 on: June 18, 2014, 08:39:53 PM »
Thank you for the insight as to setting the popup list value to the 0 index after recreating the list.  Haven't tested it, but I presume it'll work.

In regards to 'right' or 'left' of the mouse, the popup list will always appear either above or above the mouse, depending as to whether it's above/below the middle of the Y height, yes; however, it will always appear to the right of the mouse cursor, regardless if you are at the edge of the screen, at least for me.  My request for either have the ability to make it on the left or right of the mouse click with an option, or perhaps another left/right of the middle of the X axis sort of thing.

Basically, I have an item with a popup list near the far right of the screen and the popup list is going off of the visible screen.  I had to change the code to make it go to the left and was wondering if there could be an option for this.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopup List Offcenter and Always First Selection
« Reply #4 on: June 19, 2014, 05:58:38 PM »
The popup list appears aligned with the actual clickable pop-up area that brings it up. There is no left or right. It's just always aligned. If the content doesn't fit into the width of the button area, it will extend toward the right - maybe this is what you mean?