At 09:39 PM 5/5/2008, Paul Ishenin wrote: >[..] >You can turn KeyPreview of your Form to True and add OnKeyPress handler. >In your OnKeyPress handler make a check for space key and focus control >you like. > >For example: > >TForm1.Form1KeyPress(Sender: TObject; var Key: Char); >begin > if Key = 32 then > PerformTab(True); >end;
Although this works, it should be noted that the results are not identical when using the space bar and the tab key. The tab key simply moves the cursor to the next input box whereas the space bar first appends a space character to the end of the text in the edit box, then performs the tab function. This can raise an issue because the graphical representation of a space character is visually indistinguishable from "no character" so the user can't see that it is there - but the trailing space character counts as part of the length of the edit.text string and is involved when comparing strings. So if someone uses TAB to enter (in this case amateur radio callsigns which contain no imbedded spaces) and another user hits the space bar to do it, although the edit box values *look* identical in both cases the two entered strings aren't technically equal, which makes a casual check for duplicate callsign entry fail. In the above example we are presumably previewing the keystroke *before* it gets to the widgetprocessor, but it looks like the space character has already been appended to the text field by the time the onkeypress handler sees it. I don't know if this is an oversight or if it has to be done that way because that's how Delphi did it? On another point, I see the UpDown widget doesn't work exactly as expected. Normally one would expect the value (.position) to increase then the uparrow is clicked and decrease when the downarrow is clicked. That happens most of the time in the current implementation but it seems that whenever the direction changes the first click in the new direction actually performs the *old* operation first before changing the direction. For example, with a starting value of 0, if we upclick three times in a row the value goes to 1, 2, 3 just as expected. If we now click on the downarrow the value goes to 4 instead of 2. Subsequent clicks on the downarrow work as expected. I see there is a website for viewing bugs but haven't found a place to report such things. Is there an official bug-logging place? Bill _______________________________________________ Lazarus mailing list [email protected] http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
