Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [nebula-dev] Grid -How to obtain selected cell?

Hi,

You should add a mouse listener to the grid object and implement its
onMouseDown method. In this method , you can get its point.  The code
may be like this:
grid.addMouseListener(new MouseAdapter(){
       public void mouseDown(MouseEvent e){
              Point pt=new Point(e.x,e.y);
              int columnIndex = grid.indexOf(getColumn(pt));
       }
});
In the above code, the pt variable is such a point parameter that
getColumn needs.

Regards,
higer



On 7/9/09, zhong nanhai <higerinbeijing@xxxxxxxxx> wrote:
> Hi,
>
> There is a getColumn function in Grid class:
> public GridColumn getColumn(Point point)
>
> You can use this method to get the column , and then use
> Grid.indexOf(GridColumn column) to get its corresponding index
>
> Regards,
> higer
>
>
>
> On 7/9/09, Michael Lodemann <milo@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>> Hello,
>>
>> sorry for this obvious newbie question, but how can I detect which cell
>> (column index) of a GridItem is selected?
>> With "grid.getSelection()[0]" I receive a GridItem representing a row.
>> But I cannot find a method allowing me to determine which index of the
>> GridItem is selected.
>> Of course I set the flag "grid.setCellSelectionEnabled(true);".
>>
>> Thanks,
>> Michael
>>
>> --
>> M.Sc. Michael Lodemann           Dept. for Computer Science, CAU of Kiel
>> Room 1106                        Communication Systems Research Group
>>                                  Phone:    +49-(0)431-880-7289
>> Christian-Albrechts-Platz 4      Fax:      +49-(0)431-880-7615
>> 24098 Kiel - Germany             milo@xxxxxxxxxxxxxxxxxxxxxx
>>
>> _______________________________________________
>> nebula-dev mailing list
>> nebula-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/nebula-dev
>>
>


Back to the top