Archived

This topic is now archived and is closed to further replies.

Adding autocomplete to a progam.

This topic is 5748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am writing an editor for a language I have to use at work. I want to add auto-complete to it, but am having some problems. I am using a "Stay on top" window that pops up whenever you type a '':'' (This languages version of ''.'' or ''->''). But when it comes up it takes the focus. No matter how many times I try to switch focus to the editor window it doesn''t work. Anyone have any ideas? A better way to do it? A website that gives advice on this sort of thing. Ohh yeah, I''m using Borland Builder 5. Jason Mickela ICQ : 873518 E-Mail: jmickela@sbcglobal.net
Please excuse my spelling -"I''m Cloister the Stupid" Lister (Red Dwarf)

Share this post


Link to post
Share on other sites
I don''t know much about borland builder, but this is an idea that might work; maybe you should use a set of controls instead of a new window. Just draw some new controls (with controls I mean the sort of controls like in visual basic) on top of the editor textbox, so you don''t have to mess with the focus-stuff.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Have a function that brings up a dialog box the contains a listbox containg the auto complete items. Have the function return what is selected from the list box. If nothing is selected, return an empty string.

Share this post


Link to post
Share on other sites
I have already done what AP suggested.
I first hthought to use just a control on the form, but if you lok at VC++ their autocomplete can run off the edge of the window it is on, so it is not a control on the form, but it''s own window.

I know hot to implement the basic functionality, but I don''t want to focus to switch to the new window when it opens, I want the user to be able to keep typing in the RichEdit and hit return or space if the highlighted item in the listbox is what they want.

Jason Mickela
ICQ : 873518
E-Mail: jmickela@sbcglobal.net


Please excuse my spelling
-"I''m Cloister the Stupid" Lister (Red Dwarf)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You can still use the dialog box. You need to code it so that when you hit the spacebar or the enter key, it returns the selected item. Maybe code it so that the escape key will return an emtpy string.

Share this post


Link to post
Share on other sites
child window, as well as MDI frames....

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites
Thanks, I''ll try to set it up as a child window.

Jason Mickela
ICQ : 873518
E-Mail: jmickela@sbcglobal.net


Please excuse my spelling
-"I''m Cloister the Stupid" Lister (Red Dwarf)

Share this post


Link to post
Share on other sites
also, the window should be created program load and then hidden. you would fill the list box up with some data (its not a real listbox, but a specilized one) and show it in the proper place. this occers whenever you want (such as : is used and the text before matches something it can autocomplete). you would not switch focus to the listbox, but instead you would continue watching the key presses and as they are pressed update where in the list box you should be (ie the first match based on the partial match). pressing space or enter accepts the partial match, while up and down will move the hilite. ALL key presses are filtered from the edit box where the typeing occers. also you should use a child window as mentioned, but an always on top window works as well (just make sure its hidden and not being created when needed). also if there is no match, DONT default to something in the box, instead just allow the person to type as normal. escape should hide the box for the duration of typing on that word.

Share this post


Link to post
Share on other sites