Author Topic: Moving Draggable Panel with keyboard or controller  (Read 7710 times)

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
Moving Draggable Panel with keyboard or controller
« on: August 27, 2013, 07:28:45 PM »
I'm not sure if I've set up my system properly, but I figured I'd see if I was at least on the right track and get some feedback on how to get what I need done.

I setup a draggable panel for my UI that I don't really want to be dragged.  What I was mainly interested in was some kind of clipped plane that I could manually slide nested windows on and off.  How can I manually move the plane with a keyboard (Tap a key and the next window slides in)?  I'd also like to have a menu at the top of the screen with the names of the windows and clicking on the name will slide in the correct clipped plane.

I haven't found any tutorials about this, so I'm asking on the forum to see if I can get some information to get me in the right direction.

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
Re: Moving Draggable Panel with keyboard or controller
« Reply #1 on: August 29, 2013, 07:20:25 PM »
I assume by the lack of a response that this isn't possible?  If that's the case, then what would be the best way to change the panel inside a window?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Moving Draggable Panel with keyboard or controller
« Reply #2 on: August 30, 2013, 05:21:20 PM »
Just like you would move any other object. In your key handling function, TweenPosition of your windows.

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
Re: Moving Draggable Panel with keyboard or controller
« Reply #3 on: August 31, 2013, 04:33:24 AM »
Even if the windows are inside the grid?  I guess the part I'm not sure about is if I want picture #2 of 5, how do I get it to be within the display box? 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Moving Draggable Panel with keyboard or controller
« Reply #4 on: August 31, 2013, 12:49:09 PM »
Grid repositions children when the script gets activated (or you ask it to reposition). After that's done you are free to move objects as you see fit. I am not sure what you mean by 2 of 5 and within the display box.

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
Re: Moving Draggable Panel with keyboard or controller
« Reply #5 on: August 31, 2013, 05:27:55 PM »
Well, in the grid there are 7 "blocks".  Like in your example with the pieces of gear.  Let's say you want piece of gear #4 to be displayed in the center.  How would I display only that one?  Or is it as simple and throwing a TweenPosition script on the main panel and just moving that around as I want?  I tried that, but the contents of the panel kept being moved all over the world instead of in the bounding box.  So I assume there's more to it.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Moving Draggable Panel with keyboard or controller
« Reply #6 on: August 31, 2013, 08:37:29 PM »
Scroll Panels work by setting the localposition to X and the cliprange to -X, thus offsetting the clip view to be the same place on the screen. If you tween the panel somewhere, remember to counter tween the clip range.

When you have a grid, it's trivial to calculate the sizes, since the grid even exposes this (.gridSize or cellSize I don't remember the name).

Picture 2 of 5 means that your target position is cellsize*2 (onx or y depending on your active axis).


Nothin more to it.