Adding Text to Field - Is there a quicker way?

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

acidjazz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 93
Joined: Mon Feb 16, 2009 2:37 am

Adding Text to Field - Is there a quicker way?

Post by acidjazz » Mon May 11, 2009 1:50 am

Does anyone find it strange that you can't type directly into a field to create a label? We must select the field, open the property inspector, click on the "contents" section, click in the contents box, and then type. It seems weird to bury such a common action. The tooltip is on the front page, but not the actual contents? Is there a keystroke command to get to the contents page quickly?

Mark P.

acidjazz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 93
Joined: Mon Feb 16, 2009 2:37 am

Post by acidjazz » Tue May 12, 2009 1:27 am

If I recall, in Authorware you could double click on the field and type directly into it. Would it be difficult to get Revolution to do that? Or a setting in preferences that takes you immediately to the contents if you double click?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Tue May 12, 2009 2:12 am

This is something that's always bothered me about the Revolution IDE. Yes, it would make perfect sense to double-click on a label field to edit it.

Bernard
Posts: 351
Joined: Sat Apr 08, 2006 10:14 pm

Post by Bernard » Wed May 13, 2009 10:06 am

With the mouse pointer over the lable, type ctrl+M to bring up the message box. In the MB type 'set the text of the mousecontrol to "new label text" '.

This might sound like an unnecessarily complex workaround, but the principal behind it can be generalized to change the properties of many objects without opening the inspector and finding the relevant section.

It's important to bear in mind that (practically) the whole Rev IDE is dynamic and under your control. Of course, it is only easy to do things like I suggest above if you find typing easy, and if you know the names of the properties.

I do believe that GLX2 provide a free tool called 'no click inspector' which might offer you some benefit (http://glx2.com/video/2053167:Video:8150 ). Warning: that page plays music/video once you load it. I tried to find a link to the no-click property inspector on that site, but I couldn't, so I can't really tell you what it does. (I hate the design of that site so much).

acidjazz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 93
Joined: Mon Feb 16, 2009 2:37 am

Post by acidjazz » Thu May 14, 2009 11:29 pm

Thanks Bernard. At first, when I read this I thought, "Indeed this DOES sound like an unnecessarily complex workaround." :-) But, I gave it a shot, and with a bunch of fields, it does tend to be faster (although it's an odd feeling for me to place my mouse over an object *without* clicking anything). I haven't had the courage yet to mess with the IDE, but in pseudo code it might be something like this?

Code: Select all

on mouseDoubleUp
       open the property inspector of me
       set the property inspector page of me to contents
       focus on the contents' textbox
end mouseDoubleUp
OR

Code: Select all

on mouseDoubleUp
      answer ""
      put it into the field of me
end mouseDoubleUp
But where would I put this script? Wouldn't this have to be a parent script for every single field. I guess that could be dynamically set too. Hmmm....

Mark P.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Fri May 15, 2009 12:02 am

acidjazz,

you probably want to change the content of the label field when developing, not later. So instead of hacking the IDE, why don't you put temporarily something like:

Code: Select all

on mouseUp
   put the target into myTarget
   if not (the name of myTarget contains "label field") then exit mouseUp
   ask "what should the content of me be"
   if it is empty then exit mouseUp
   set the text of the target to it
end mouseUp
into the script of the stack? You could even ask for a name for this field. You just create a bunch of label fields and then you set their content and if you wish their name. Afterwards you delete this handler.
Or even more generic: you put this handler into a separate stack with this script and when developing you 'start using' that stack (which this developer helper stack of yours initiates when it is opened) In short a library. That way you dont modify the IDE and still have your extra tools for developing.

And I agree, I also find the inspector has a lot of room for improvements. I used to use the GLX2 property inspector which is a easier to navigate, but lately I did used gradients a lot and that he doesnt understand.
regards
Bernd

Bernard
Posts: 351
Joined: Sat Apr 08, 2006 10:14 pm

Post by Bernard » Fri May 15, 2009 9:31 am

Mark P.

Here's another variant (if clicking on a control makes you feel more comfortable!)

Click on label field
ctrl+m
type 'set the text of the selobj to "easy peasy" '

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Fri May 15, 2009 1:05 pm

I think Bernd has the right approach, but if you really want to look at delving into the IDE, then in the Toolsets folder you will find the revtools.rev stack. If you open that and edit the script of the first card, you will find a handler "revCreateObject" in which you will find the default settings for all the controls that you may drag onto a card from the tools palette. You could change the default names for instance, or add other properties. eg in the case "label" part of the switch statement you could add a line

Code: Select all

set the cProperties["type"] of the templateField to "label"
which will add a type property into a new custom property set cProperties (so as not to get mixed up with regular custom props)which you could then interrogate to determine more specifically that it's a custom Label that you want to be able to do things with as suggested by Bernd. If you wanted to be more sophisticated you could instead create objects with default behaviors by adding the lines in the revCreateObject handler, as long as you can tie the behaviors to a fixed parent id.
Needless to say, this will not be supported by RunRev, and you must back up your system before you try anything out like this.

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

Post by BvG » Sat May 16, 2009 1:08 pm

I have made a library because exactly this also enervates me to no end:

How to use:
  1. You make a stack named "labelEditor" containing the first script.
  2. Now name the (first and only) card of the stack "labeleditor"
  3. Then create a custom property called "templateScript" for that stack, and set it to the second script.
  4. Now you save the stack to the plugin directory (it's where the Rev IDE is installed to).
  5. Finally you go to the menu: "Development" -> "Plugins" -> "Plugin Settings", and make the stack you just saved start invisible,when the IDE starts. (Choose "Revolution starts up" and "Invisible").
Note that this will only work when the browse tool is selected, as you can't get mouseDoubleUp with the edit tool. I tried one or two days to get the edit tool work seamlessly, but I was unable to do so.

Code: Select all

--this first script goes into the script of the stack
on openstack
  if the target = "card" && quote & "labeleditor" & quote then
    start using me
  end if
  pass openstack
end openstack

on mousedoubleUp
  if the name of the target = "field" && quote & "Label Field" & quote then
    clone the target
    set the script of it to the templateScript of me
    set the boss of it to the id of the target
    set the locktext of it to false
    set the traversalon of it to true
    set the loc of it to the loc of the target
    set the showborder of it to true
    set the autohilite of it to true
    set the opaque of it to true
    select the text of it
  else
    pass mousedoubleUp
  end if
end mousedoubleUp

on docleanup theID
  delete field ID theID
end docleanup

Code: Select all

--this second script goes into the custom property "templateScript" of the stack
on closeField
  finished
end closeField

on exitField
  finished
end exitField

on returnInField
  finished
end returnInField

on enterInField
  finished
end enterInField
on finished
  put the text of me into field id (the boss of me)
  send "doCleanup" && the id of me to this stack in 0 seconds
end finished
Various teststacks and stuff:
http://bjoernke.com

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

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Sat May 16, 2009 7:02 pm

Bjornke- nicely done. The only problem I see with it is that I usually rename my label fields to something like "lblFirstName" to match the "fldFirstName" text entry field. And since label fields are just text fields with certain configurations set, it's hard to differentiate between them otherwise than using the "Label Field" name. Maybe just checking to see if the text is locked would be a better test than using the name...

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

Post by BvG » Sat May 16, 2009 7:10 pm

well of course my approach for my own needs does not match what you would need, so simply adjust accordingly :P
Various teststacks and stuff:
http://bjoernke.com

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

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Sat May 16, 2009 7:48 pm

mwieder wrote:Bjornke- nicely done. The only problem I see with it is that I usually rename my label fields to something like "lblFirstName" to match the "fldFirstName" text entry field. And since label fields are just text fields with certain configurations set, it's hard to differentiate between them otherwise than using the "Label Field" name. Maybe just checking to see if the text is locked would be a better test than using the name...
Snap Mark, that's exactly my policy too. (And that's why I mentioned editing the revtool.rev stack to add a custom property to the label fields by default, so that you could test for this property to see if it was definitely a label as opposed to any other field type. As it happens I also set the default name of a label field to "lbl" and a regular field to "fld" so that it was simple just to add the name after the prefix, so in theory I could just check whether the name of the field begins with "lbl" but... you know...)

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Sat May 16, 2009 8:51 pm

Well, having been through the revTools code before, it's a bit of a jungle. What I'd do in that case is find the section that creates a new label field object and insert code that adds a custom property to the templateField before the new field gets created. That way you could check the custom property of a field in a frontscript handler and act accordingly. The downside is that you'd have to do this for each new rev release, which is a bit of a pita. It's probably not worth the effort just for this.

acidjazz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 93
Joined: Mon Feb 16, 2009 2:37 am

Post by acidjazz » Sat May 16, 2009 10:24 pm

Wow! Quite a conversation. This is great. The revTools stack certainly is a jungle. Fascinating to read the programmers comments about bugs though! I felt like a spy. And then, just as SparkOut warned, I corrupted the file (but had made a backup, so it's okay). It would be useful to know what I did that messed it up. I was using Notepad++ (a code text editor) to make very tiny changes. In revTools.rev there is rev-like code at the top, and then the same code in html at the bottom. I was delicately messing with the html when bad things happened. the IDE would hang when opening up.The reason I was using the text editor is because it seemed to be confusing the IDE to be trying to edit the tools palette. It kept saying "You already have this open." Even when I tried to change the name to revTools1.rev, it still seemed upset.

Anyway, now I'm playing around with Bjornke's plug-in. Very nice. Yes, it would be great if some sort of keystroke combination would allow you to go from browse to edit mode. I've got a 24" monitor at the highest resolution, so I probably sound lazy, but that tools palette sometimes seems awfully far away! And in any case, it's still cool, I'm learning quite a bit, and appreciate all the helpful comments!

Mark

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Sun May 17, 2009 1:07 am

Mark- We talking about the same revTools.rev? (I also use NotePad++, but not for editing rev scripts). There's no html code in my copy of the scripts. If you do feel inclined to play around with this, look in the revCreateObject handler in the card script. There's a big switch statement in there and one of the switch cases is "label". That's the one you'd want to modify.

...and as a side note, if you have glx2 installed one of the free options (whether or not you have a license to use the script editor) is the ability to switch between browse and edit mode with control-tab.

Post Reply