New, need very, very simple help with buttons

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
TodayIsTheDay
Posts: 56
Joined: Sat Jun 20, 2009 2:41 pm

New, need very, very simple help with buttons

Post by TodayIsTheDay » Sat Jun 20, 2009 2:56 pm

Hello, I'm new to RR and have only very basic knowledge of programming. Need some very basic help with buttons.

I'll probably post about a million other questions if that's ok...

I'm not great at explaining things sometime so I make videos...


http://screencast.com/t/Z4iwwvjYpT9

Thanks!

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

Post by Klaus » Sat Jun 20, 2009 3:13 pm

Hi todayistheday (where do all you guys get those crazy nicks??? :-D)

OK, here the answers (as I understood your problem)
1. Use a "on mouseenter" handler to do things when the mouse "rolls" over a button (or any other object).

Like this:

Code: Select all

on mouseenter
   put "Click here or get lost" into fld "Info"
   ## Optional use another field with premade text:
   ## put fld "the (maybe hidden) field with the long info text" into fld "info"
end mouseenter
To "clear" the info field again when the user moves the mouse off of the button you can use "mouseleave"

Code: Select all

on mouseleave
   put empty into fld "info"
end mouseleave
2. This looked like another stack(?) that you want to show when the user clicks a button:

Code: Select all

on mouseup
  go stack "the stack with your TAB buttons here..."

  ## Or go to another card in the same stack as the button:
  ## go cd "card with the TAB buttons on it"
end mouseup
Pretty simply, once you know it :-D


Best from germany

Klaus

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

Post by Klaus » Sat Jun 20, 2009 3:16 pm

Oh, I forgot:
Welcome to the forum! :-)
Last edited by Klaus on Sat Jun 20, 2009 3:32 pm, edited 1 time in total.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Sat Jun 20, 2009 3:26 pm

Nice use of video :)

for hovering there are (as often) several possible ways to do it. One that is not 100% reliable (but most of the time) would be this:

Code: Select all

on mouseEnter
  put "mouse is within" && the short name of me into field 1
end mouseEnter

on mouseLeave
  put "mouse is not over a button" into field 1
end mouseLeave
Another way is to not use a field, but enter text into the "tooltip" part of the property inspector for each of your buttons.

for changing the stuff that is currently shown on a stack ("stack" can mean various things in Rev, here it is a synonym for window) there's mostly 2 approaches:

showing/hiding groups:
You can group all the objects that belong together, and then set the "visibility" of the group to false/true. This is faster then hiding/showing each object by itself, and also easier to manage in code.

so for a tab button, you could create groups that are named the same as the items that the user can choose in the tabs:

Code: Select all

on menupick thePickedItem thePreviousItem
  --first hiding the previous one
  hide group thePreviousItem
  --now show the one the user clicked on
  show group thePickedItem
end menuPick
using cards:

this is easier if you already used hypercard before, as the concept of cards would be known to you. basically each card is a "view", and a card is always part of a stack. you can do various things with cards, like store them for later reference (with "push" and "pop"), or just for hiding stuff from the user (by not giving him a way to navigate to the card).

For a tabbed button, you'd need to put the tabs into a group, and set that groups "backgroundbehavior" to true, and then you'd need to "place" said group onto each card that is part of the tabbed behaviour (this is done automatically if you create a new card). the code could then look like this, if you'd have named your cards the same as all the tabs:

Code: Select all

on menuPick theCurrentChoice
  go card theCurrentChoice
end menuPick
I suggest to read all the tearms i mentioned above in the dictionary. Even if it's a bit overwhelming at first, something is bound to stick, and "browsing" trough the terms via the "see also" links is a good way to read about similar, or related topics.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

TodayIsTheDay
Posts: 56
Joined: Sat Jun 20, 2009 2:41 pm

Post by TodayIsTheDay » Sat Jun 20, 2009 5:32 pm

Thank you!

More question...

1. Do you have to go to a new window or can the entire page you were on be the new window. i.e.- can it just simply redraw the contents.

2. Once I'm previewing and "running" the program. How do I get back to be able to edit?

http://screencast.com/t/Ym0QGc53hGa

I know I've got a couple more questions about the tab use. I'll post that in a few...

Thanks again.

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

Post by Klaus » Sat Jun 20, 2009 6:50 pm

Hi Today,

1. I would suggest to use different cards in your (same) stack to display different content.
This way everything will happen in the same window.

And it is easy to navigate, see my last post:

Code: Select all

...
   go card "Name of cd with the TAB buttons"
...
2. This is extremely easy:
Just change the tool in the tools palette to "pointer" tool = the arrow with the little cross underneath.

This is one of the big benefits of Rev: No compiling to run the "app", just switch the tool :-)


Best

Klaus

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

Post by Klaus » Sat Jun 20, 2009 6:53 pm

P.S.
Be sure to work through these stacks here, which are extremely helpful to understand how everything works in Rev:
http://www.hyperactivesw.com/revscriptc ... ences.html

I make the one about "controls" ;-)

TodayIsTheDay
Posts: 56
Joined: Sat Jun 20, 2009 2:41 pm

Post by TodayIsTheDay » Sat Jun 20, 2009 7:40 pm

Thank you! I'm going to dig a little more and keep at it.

I appreciate your help!

Patrick

Post Reply