Ben Combee wrote: > > At 08:06 AM 7/9/2004, you wrote: > >The prototype: > > > >Boolean TblGetSelection (const TableType *tableP, Int16 *rowP, Int16 > >*columnP) > > > >Parameter description: > > > >-> tableP Pointer to a table object. > ><- rowP, columnP The row and column indexes (zero-based) of the > >currently selected item. > > > >Question: > >It appears (at least for PalmOS 5.2.8) that the returned values of row > >and column are zero if nothing is selected, but since the row and column > >indices are zero-based that is in the valid range. Shouldn't the > >returned row and column values be out of the valid range, for example > >-1, when nothing is selected? > > Use the actual Boolean return value of TblGetSelection to tell if anything > is highlighted at the moment; it will be true if there is a selection, and > it will be false if there is no selection. > > -- Ben Combee, DTS technical lead, PalmSource, Inc. > Read "Combee on Palm OS" at http://palmos.combee.net/
Hi Ben, I don't know, but the way Palm OS handles table highlighting doesn't seem to match the documentation. At first I was thinking it was some anomaly concerning row 0. After more testing, it seems the problem can occur at any row. Here's a brief description of the application, when the problem occurs, my uneducated guess concerning the cause, and the work-around I'm using. The application shows a table of records, ten records at a time. The user taps on a row to select (and highlight) a record. I'd like the application to keep that record highlghted as the user scrolls either one record at a time via the repeat controls or 10 records at a time via the hardware page up and page down control. The way I implement this was to draw the new page of records and then check to see if one of the newly displayed records is the selected record. If so, the application selects it with TblSelectItem. The problem occurs when a selected record is scrolled into the table at the same row where it was before it was scrolled out of the table. In that case, TblSelectItem will not highlight the record. For example, if the selected record is the last row of the table (i.e., row 9), scrolling up one record will cause the selected record to go out of the table's range. Then scrolling down one record will cause the selected record to come back to the last row of the table. In that case, TblSelectItem will not highlight the record in row 9. Scrolling down another record will put the selected record in row 8 and then it gets highlighted again. Scrolling up puts it in row 9 where it is still highlighted. But TblSelectItem will not highlight the selected record if it gets scrolled out of the table's range and then scrolled back so that it appears in the same row it had previously occupied in the table. Using the repeat controls, the same occurs at row 0. And using the page up/down controls, the same occurs at any row by paging up/down 10 records and then down/up 10 records. My guess is that TblSelectItem is unhighlighting the previously highlighted row *after* it highlights the specified row. So when the previously highlighted row is the same as the specified row, the end result is no highlight. A work-around is to call TblUnhighlightSelection just before TblSelectItem. Now looking at other applications, I see that this work-around is fairly common. Should it be mentioned in the Palm OS reference or the Palm OS companionn documents? I think the high quality of the Palm OS documentation is what has attracted so many programmers. This problem was the first time I have had to take a day to understand how the Palm OS documentation differs from the OS. Unfortunately that is a common occurrence with other OSs. Thanks for all the support you've given this group. Greg -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
