Author Topic: Question about a window that will be dragging  (Read 5088 times)

recon03

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Question about a window that will be dragging
« on: September 21, 2014, 12:25:13 AM »
I have a inventory window I made, and I'm also able to drag.  The issue is it can go out of the bounds of the screen view and it can get lost by the user.  Looking for someone to lead me in the right direction to solve this.  I'm not looking for someone to do this for me , just point me in the right place, this is for a Capstone for my school and I choose to use NGUI since I knew most other programs. I'm still learning NGUI. I do understand about 60% of it so far I  think .


Thanks in advance for any help.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Question about a window that will be dragging
« Reply #1 on: September 21, 2014, 09:08:44 AM »
Have a look at the examples that come with NGUI. Those that contain draggable windows also  have them restricted to not leave the screen. It's done by using the "Keep Visible" option on the UIDragObject script. Specify the Panel Region to be your UIRoot and the Content Rect to be your window's content region, whatever it may be. If you don't have one, create a UIWidget (ALT+SHIFT+W) and resize it to cover your window and use that as the Content Rect. Don't forget to push it back in depth so it doesn't intercept all your events though.

recon03

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Question about a window that will be dragging
« Reply #2 on: September 21, 2014, 06:09:39 PM »
Nm , I got it Thanks.
« Last Edit: September 21, 2014, 06:52:15 PM by recon03 »

recon03

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Question about a window that will be dragging
« Reply #3 on: September 22, 2014, 02:21:12 PM »
Aren is this suppose to leave the screen and then snap back???  I still can't get it to stay in the screen, it leaves the screen area, and when I release  on mouse down, it snaps back. I did this with the example.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Question about a window that will be dragging
« Reply #4 on: September 23, 2014, 11:06:59 AM »
If the draggable object's momentum is "spring", then yes.