Creating an intellisense effect on a field?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bmcgonag
Posts: 40
Joined: Thu Mar 13, 2014 6:51 pm

Creating an intellisense effect on a field?

Post by bmcgonag » Thu Mar 13, 2014 6:58 pm

I have a single entry field for multiple words, and I'd like to create an intellisense type effect for my user when they are entering into that field.

So based on what they start typing I provide options for them to tab through, then prompt for the next item needed, and provide suggestions as they type. Any way to accomplish this effect in live code?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: Creating an intellisense effect on a field?

Post by dunbarx » Thu Mar 13, 2014 7:19 pm

Hi.

Absolutely.

But how do you want this "help" gadget to work? A small floating field next to the entry field? Or near the insertion point? Perhaps an option menu with choices based on the most recent word? Some CAD programs have a sort of command line at the bottom of the window.

The contents of that help thing, whatever it turns out to be, can be populated, and the type of help object itself selected, based on the text entered. A few more details would help.

But just as importantly, can you give us a brief summary of how well you know LiveCode? It will matter in terms of how we help you...

Craig

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Creating an intellisense effect on a field?

Post by jmburnod » Thu Mar 13, 2014 7:32 pm

Hi bmcgonag,

Do you mean "words prediction" ? In this case "filter" should be useful for your goal.
As Craig said there are many ways to do what you describe.
Choosing the best way is often the main part of the job.

Best regards
Jean-Marc
https://alternatic.ch

bmcgonag
Posts: 40
Joined: Thu Mar 13, 2014 6:51 pm

Re: Creating an intellisense effect on a field?

Post by bmcgonag » Fri Mar 14, 2014 3:23 am

I appreciate the quick responses. Sounds like what I'm wanting to do will likely be possible.

First off, I am very new to LiveCode, but excited to see what I can do. From the tutorials, and videos I've seen of it so far it looks great. I can program, and have done so in Xcode, Javascript and Jquery, C++, Visual Basic, Turbo Pascal, and yes even in QBasic and Basic a looooonnnnnggg time ago.

As for what I'm looking for more specifically.

I'm creating a game (more for fun than anything else), and it will be very much modeled after the linux / unix terminal command line.

Rather than asking my player to learn a bunch of commands, options, and so on, I'd rather prompt them once they begin typing (similar to how Xcode and Visual Studio prompt you by showing the available methods matching what you're typing, and then providing the next pieces to that method).

For instance if you do UIV in Xcode, it will pop-up

UIView

Then you can tab or press Enter to select that for autocomplete, and once done it prompts for the rest of the parameters needed for adding a UIView. It highlights the next parameter you're expected to enter as you complete each current parameter and add the delimiter).

I'm wanting to do something similar to this. So that as my user types a command, I can show matching options for autocomplete. Once they select a command, or finish typing their command I would then like to prompt them for the necessary parameters of that particular command. The highlighting of each 'next' parameter would be awesome, but not completely necessary.

Not only would this be useful for my game, but I know of tons of data entry applications that could benefit from such a tool, so writing something, learning how it works, and then going back and turning it into a reusable object that can be shared with others would also be ideal.

Thanks again, and I'm looking forward to the responses and suggestions.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: Creating an intellisense effect on a field?

Post by dunbarx » Fri Mar 14, 2014 3:54 am

Hi.

It sounds like several lists of words or phrases might be stored in a custom properties of the main entry field. Each list can be loaded into, say, a menu-type button upon completion of a word or phrase in that field.

So imagine two lists, each the contents of a custom property, one property named "fudge" and one named "poison". The "fudge" property might contain:

"chocolate"
"hot"
"vanilla"

and the "poison" property might contain"

"Thallium"
"Polonium"
"Arsenic"

Please read up on the "keyDown" message in the dictionary. You might monitor the contents of the entry field, character by character, and note the most recent word or phrase. If that text happened to be "poison" (or "murder" or "unfaithful spouse"), you could show the menuButton and load its options with the contents of the property.

I prefer "Thallium".

I recommend you make this gadget. It will be a terrific first foray into LC, and will utilize a wide range of basic skills. Help is available here in copious quantities, as long as you are actively working on your project. Write back any time with any question whatsoever, as long as it is not "Please write my code for me".

Craig

bmcgonag
Posts: 40
Joined: Thu Mar 13, 2014 6:51 pm

Re: Creating an intellisense effect on a field?

Post by bmcgonag » Fri Mar 14, 2014 4:03 am

No worries, I prefer to write my own code.

I appreciate the pointer, and it sounds like a possible winner. I will keep going with the basics until I start to get the hang eo fLC more. Then I will give this a try. IF I run into a snag I'll be sure to post back! Thanks so much!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: Creating an intellisense effect on a field?

Post by dunbarx » Fri Mar 14, 2014 4:54 pm

Hi.

Rereading, I see you are more interested in auto-complete as opposed to listing related words. Not a problem. I suggest you start with a clean card and a field. Put a "keyDown" handler in the script of that field, one that does something fun with whatever text you type. This can be simply be spitting back the last char typed, the last word typed, the ascii value of that last char, anything, and put that result into another field. Now place a few words in yet another field, and modify the handler to "find" those words, perhaps if three or more characters in the last word match it.

That sort of thing. If you do all this, you will be 75% of the way to your auto-fill gadget.

Craig

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

Re: Creating an intellisense effect on a field?

Post by mwieder » Sat Mar 15, 2014 2:39 am

Auto-completion can certainly be done. GLX2 does this to predict/auto-complete handler names. You'll need to handle several messages; keyDown, rawKeyDown, backspace, etc.
And I'd advise not kicking it in until a few characters have been typed - it's a bit disconcerting to type a single character and have a scrolling list of every word that starts with that character suddenly appear.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10354
Joined: Wed May 06, 2009 2:28 pm

Re: Creating an intellisense effect on a field?

Post by dunbarx » Sat Mar 15, 2014 4:20 am

Mark makes a point. I always start at three chars.

The trick is to be able to discern either single words or phrases of a few words. These may each have their own requirements. So make sure you understand the concept of "chunks" as they are defined and used in LC, and how to parse them.

All loads of fun. Good luck. Write back...

Craig

bmcgonag
Posts: 40
Joined: Thu Mar 13, 2014 6:51 pm

Re: Creating an intellisense effect on a field?

Post by bmcgonag » Sat Mar 15, 2014 5:26 pm

You folks are awesome!

You are explaining exactly what I'm looking to do. I appreciate the hints about using 3 characters as appropriate, and the hint about chunks as well.

Definitely will be looking into those. The biggest learning curve for me will be the syntax of live code, but I think it's going to be great too.

Post Reply