How to set location of new object to another but lower!

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
heatherbee
Posts: 8
Joined: Wed Jul 23, 2008 11:34 am

How to set location of new object to another but lower!

Post by heatherbee » Wed Jul 23, 2008 1:33 pm

This is what I want to do:

When user clicks button, create a new field which appears by fade in under the existing field.

Here's what I have so far (please note, not that I need to point it out, that I am a complete beginner to Rev and to programming in general :-D):

Code: Select all

on mouseUp
  create field "newField"
  hide field "newField" 
  -- to be located first then fade into view
  set the location of field "newField" to the location of field "firstField" -- PLUS X OR  something to move it under it?!
  show field "newField" with visual effect dissolve
end mouseUp
Thanks for helping a n00000bee. :D

heatherbee
Posts: 8
Joined: Wed Jul 23, 2008 11:34 am

Post by heatherbee » Wed Jul 23, 2008 2:02 pm

Okay, I got it working now with the following code, but when the new field is displayed it's briefly visible before it hides. Is there another way to create it invisibly then bring it in with the fade in type effect?

Here's what works for now anyway (no doubt there's a much easier way to do this, like with a function or something and a lot less code, but I haven't learned that far yet!):

Code: Select all

on mouseUp
  create field "newField"
  hide field "newField"
  -- to be located first then fade into view
  set the width of field "newField" to 300
  set the height of field "newField" to 25
  set the location of field "newField" to the location of field "firstField"
  move field "newField" relative 0,30 without waiting
  show field "newField" with visual effect dissolve
end mouseUp
Thanks in advance for any ideas on how to not have the flashing new field!

bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

Invisible field

Post by bjb007 » Wed Jul 23, 2008 3:25 pm

Use "create invisible field "newField""
Life is just a bowl of cherries.

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Wed Jul 23, 2008 3:29 pm

Hi heatherbee,

welcome to the revolution. If you want to avoid the flicker try locking screen before you create the field.

Code: Select all

on mouseUp
  lock screen
  create field "newField"
  hide field "newField"
  -- to be located first then fade into view
  set the width of field "newField" to 300
  set the height of field "newField" to 25
set the loc of fld "newField" to item 1 of the loc of fld "oldField",item 2 of the loc of fld "oldField" + 30
  unlock screen
  show field "newField" with visual effect dissolve
end mouseUp
You might also want to look up templateField in the dictionary. If you set properties of the templateField, all newly created fields inherit its properties.

Hope that is any help,

Malte
Last edited by malte on Wed Jul 23, 2008 3:29 pm, edited 1 time in total.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Wed Jul 23, 2008 3:29 pm

Hi heatherbee,

you can create an invisible field if you like:

Code: Select all

on mouseUp
  create invisible field "newField"
  set the width of field "newField" to 300
  set the height of field "newField" to 25
  ## set the location of field "newField" to the location of field "firstField"
  ## ??? See below...

  ## move field "newField" relative 0,30 without waiting
  ## This will not be visible, so what is this good for?
  ## Maybe you want to set the new loc (y + 30) directly like:

   put the loc of fld "firstField" into tNewloc
   add 30 to item 2 of tNewloc
   set the loc of fld "newfield" to tNewloc

  ## Now calculate and set the LAYER of the new field:
   set the layer of fld "newfield" to (the layer of fld "firstField" - 1)

  ## Finally show the beast...
  show field "newField" with visual effect dissolve
end mouseUp
Done :-)

Hope that helps.


Best from germany

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Jul 23, 2008 5:37 pm

Hi,

Why so difficult?

Code: Select all

set the loc of fld x to the loc of fld y -- you could take item 2 of the loc if you want
set the top of fld x to the bottom of fld y
Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Thu Jul 24, 2008 11:15 am

Hmm...

Looks like I misinterpreted "...UNDER the existing field" completely.

In case heatherbee really meant "below" ;-)

heatherbee
Posts: 8
Joined: Wed Jul 23, 2008 11:34 am

Post by heatherbee » Sun Jul 27, 2008 4:44 pm

OH thanks so much guys! LOL sorry Klaus am 36 and still learning to speak normal Engrishh let alone Revanese! :) Mark, sheesh I only started a few days ago so everything is bloomin difficult! :D

Post Reply