[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: Table issue
|
Shawn Spiars wrote:
> dnise wrote:
>> Shawn Spiars wrote:
>>
>>> eclipse.org
>>
>> Hi
>> Thanks you advice . but i can't find what i want .assume as follow it's
>> a table
>>
>> ------------------------------------
>> | column1 | column2 | column3 |
>> |-----------------------------------
>> | ff1 | ff2 | ff3 |
>> ------------------------------------
>> | kk1 | kk2 | kk3 |
>> ------------------------------------
>>
>> we can select a row when i click. we can use follow codes to get
>> TableItem TableItem [] tableItem=table.getSelection();
>> we can add some Listeners for this tableItem. But it doesn't complete
>> what i
>> want. we can select a row when i click on ff1 ãff2ãff3ãkk1ãkk2 or kk3.
>> the function which i want to implement is that trigger some event when i
>> click on ff3 or kk3 but not ff1,ff2,kk1,kk2.
>> can i implement it?
>>
>> thanks
>>
>> best regards
>>
>> dnise
>
>
> You might try using a mouseListener on the table and then determining
> the selected cell using the mouseUp event. See snippet below.
>
> table = toolkit.createTable(parent,
> SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
>
>
> table.addMouseListener(new MouseAdapter() {
> public void mouseUp(MouseEvent event) {
> Point point = new Point(event.x, event.y);
> TableItem item = table.getItem(point);
>
> if (item != null) {
> int columnCount = table.getColumnCount();
> for (int i=0; i < columnCount; i++) {
> Rectangle rect = item.getBounds(i);
> if (rect.contains(point)) {
> System.out.println("table item column: " + i);
> System.out.println("table item: " + item.getText(i));
> }
> }
> }
> }
> });
Hi:
Thanks for you replying . I can implement this for the moment. According to
your code,it got position of column that i wanted to operate. if the column
fixed or the column counts doesn't change, i can finished . but if the
column counts changed ,for example ,in my application, users get
information on the basis of theirs authorization. So sometimes it would
display 4 columns, sometimes show 3 columns. i can set the operation
column at last in table ,the mainly cause is column index has been
changed.
could i get the last column position while the column counts changed?
Thanks & regards
dnise