久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Mouse Up 上獲取 SWT 列表中的項目

Get the item in the SWT list on Mouse Up(在 Mouse Up 上獲取 SWT 列表中的項目)
本文介紹了在 Mouse Up 上獲取 SWT 列表中的項目的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我想知道是否可以在鼠標上移時獲取列表中的項目?我在網上搜索并找到了許多使用 X 和 Y 坐標但沒有使用列表的 SWT 表示例.我基本上在做的是實現一個列表,其中項目的順序可以通過拖放來更改.為此,我需要能夠獲取放置位置下的項目,以便我可以將該項目與拖動的項目交換.

I wanted to know if its possible to get the item in the list on mouse up? I searched online and found many examples for SWT table using the X and the Y coordinate but none using a list. What I am basically doing is implementing a list in which the order of the items can be changed by drag and drop. For this I need to be able to get the item under the drop location so that I can swap that item with the dragged item.

推薦答案

List#getItemHeight() 返回一個item所占區域的高度.有了這些信息和 getTopIndex(),您應該能夠在給定的 x 和 y 坐標處計算項目.

List#getItemHeight() returns the height of the area one item occupies. With that information and getTopIndex()you should be able to compute the item at a given x and y coordinate.

list.addListener( SWT.MouseDown, new Listener() {
  @Override
  public void handleEvent( Event event ) {
    int itemTop = 0;
    for( int i = 0; i < list.getItemCount(); i++ ) {
      if( event.y >= itemTop && event.y <= itemTop + list.getItemHeight() ) {
        System.out.println( "Click on item " + list.getItem( list.getTopIndex()  + i ) );
      }
      itemTop += list.getItemHeight();
    }
  }
} );

或者,您可以使用帶有 setHeaderVisible( false ) 的單列表來模擬列表小部件.該表提供了更好的開箱即用拖放支持.

Alternatively you could use a single-columned table with setHeaderVisible( false ) to emulate a list widget. The table provides better drag and drop support out of the box.

這篇關于在 Mouse Up 上獲取 SWT 列表中的項目的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 国产资源在线播放 | 亚洲精品久久久久久久久久久久久 | 欧美a区 | 国产精品毛片 | 精品一区二区三区四区五区 | 一区二区三区在线 | 欧美日韩在线免费 | 欧美成人一区二区三区片免费 | 日韩精品一区二区三区在线观看 | 亚洲逼院| 日韩在线资源 | 一区二区三区免费 | 神马九九| 黄色网址大全在线观看 | 三级成人在线 | www.国产精| 99re在线视频观看 | 人人看人人干 | 国产成人一区二区三区 | 久久亚洲一区二区三区四区 | 激情网五月天 | 久久久天堂 | 天天操欧美 | 男女视频在线观看 | 国产亚洲精品区 | 午夜丰满少妇一级毛片 | h在线看| 午夜天堂精品久久久久 | 亚洲午夜精品久久久久久app | 中文字幕在线视频精品 | 国产精品久久久久一区二区三区 | 可以看黄的视频 | 国产精品美女久久久久久免费 | 蜜桃视频一区二区三区 | 四虎影视一区二区 | 久久成人18免费网站 | 国产精品观看 | 国产午夜精品久久久久 | 久久久久久久一区 | 久久免费观看一级毛片 | 国产精品久久精品 |