Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Change Height of Rectangle on Keypress ?

I am trying to figure out how to change the height of a box when a user presses up on the remote. 

Heres the component:

<component name="PlutoScene" extends="Scene">

  <script type="text/brightscript" uri="pkg:/components/homescreen.brs" />

<LayoutGroup id="root">
      <Rectangle id="header" width="1280" height="300" color="0x000000"> 
      <LayoutGroup id="body" layoutDirection="horiz">
        <Rectangle id="rect1" height="270" width="400" color="0xffffff" />
        <Rectangle id="rect2" height="270" width="2" color="0x000000" />
        <Rectangle id="rect3" height="270" width="878" color="0xffffff" />
      <Rectangle id="footer" width="1280" height="150" color="0x000000">

Here is the function in the homescreen.brs file:

sub init()
  m.rect1 ="rect1")
  m.rect = m.rect1.boundingRect()
end sub

function onKeyEvent(key as String, press as Boolean) as Boolean
  if press then
    if (key = "Up") then
      m.rect.height = m.rect.height * 2
    end if
  end if
end function

I have tried a few things like just calling rect1.height = rect.height*2. 

Is the if statement correct? Am I grabbing the component correctly? What concept am I missing?
0 Kudos
Streaming Star

Re: How to Change Height of Rectangle on Keypress ?

I think the keys are lowercased, so try "up" instead of "Up"
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.