Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


PopUp giving error when "enter" without selected item

Posted on 1999-07-24
Medium Priority
Last Modified: 2010-04-04
I have a lot of popupmenus which i popop programmatically. When they first appear, no item is selected. When then the "return" key is pressed (with nonitem selected) my program causes an error (which delphi doesnt detect). Is there a way to either force the first item to be selected or trap the pressing of the return key (you can press all other keys without causing the error)

Question by:hatecapletters
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 1390972
Try setting one of the options in the popup as a "default"


Mypopupmenu.items[0].default := true;

Hope this is of some use.

Author Comment

ID: 1390973
sorry, i have the first item in each popup menu set to default, didnt help
LVL 27

Accepted Solution

kretzschmar earned 600 total points
ID: 1390974
hmm hatecapletters,

if i press return on a popupmenu, where is nothing selected, nothing happens.
But you can force the select for the first-item by doing this in the onPopUp-event

procedure TForm1.PopupMenu1Popup(Sender: TObject);


Author Comment

ID: 1390975
hello kretzschmar  :-)

as always , effective and right to the point !

i don't know why it happens when I hit return..the funny thing is that Delphi doens't catch the error.

Thanks a lot



Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question