Link to home
Start Free TrialLog in
Avatar of tcywlw
tcywlw

asked on

Something similiar to VB Code Editor ???

I would like to create a editor that is similiar to
VB code editor. I also have this config file :

[StartA]
Apple
Angle

[StartB]
Boy
Bay
Baby

[StartC]
Car
Care
Cole
Caution


So, when I type StartA with a period, like StartA., then
I will see a square box will a list of Apple, Angle to
let me select. When I select Angle, and hit ENTER or use
mouse click somewhere on the editor, then Angle will
be appended to StartA., just like StartA.Angle.

If I type StartD., I should not see square box, because
StartD does not appear in the config file.


A very simple exmaple is welcome. If this is a complicated
program, please give me detial for how to do it. Thanks !

Avatar of Nazdor
Nazdor

You could process the keypress event - when they press a "." scan backwards to get the word they just entered "StartA".

Then have a class which holds the list of available "dropdowns" (or "properties" for want of a better word).

Given a collection which holds all the top level (StartA/B/C), you can easily get the class from that collection.  

If the class itself holds a collection of the class objects, then it can be used to drill down the various properties (only 1 in your case, but could easily be extended).

eg:

' ClassProp

public Name as string
private col as collection

...various functions for adding/remove/lookup in col...

public sub AddProp(strName as string)
   dim obj as ClassProp
   set obj = new classprop
   obj.name = strname
   col.additem obj, strname
end sub



Once you have a list of available properties for any given property, you could populate a floating listbox filled with the properties, positioned to the correct place (you'll probably need some API calls to find the screen location to display the listbox).  Set the listbox focus when it appears then close it on lose focus event (to handle clicking elsewhere) or close it on certain keypresses to the listbox (eg enter, space, dot)

Then when hiding the listbox, add the listbox.text to the edit window.

The hardest bit will be positioning the listbox.


Avatar of tcywlw

ASKER

Nazdor,

Sound like what I have in my mind. But can you give me
more infor on collection ?
ASKER CERTIFIED SOLUTION
Avatar of Nazdor
Nazdor

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DanRollins
Hi tcywlw,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Nazdor's comment(s) as an answer.

tcywlw, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept THIS comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer