久久久久久久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:獲取當前星期幾的值)
主站蜘蛛池模板: 久久久.com| 在线观看成人小视频 | 国产成人精品区一区二区不卡 | 国产成人高清在线观看 | 国产一级免费视频 | 成人不卡 | 中文字幕在线第一页 | 欧美日一区二区 | 精品国产一区二区国模嫣然 | 日韩av成人在线 | 午夜久久av | 黄色大片在线视频 | 欧美在线a| 日韩欧美一区二区三区免费观看 | 国产精品视频一二三 | 日本在线一区二区三区 | 免费视频成人国产精品网站 | 亚洲国产成人精品女人久久久 | 色综合久久天天综合网 | 国产精品特级片 | 亚洲国产精品久久人人爱 | 欧美一级精品片在线看 | 99色在线视频 | www.99精品| 欧美精品一二区 | 国产精品久久久久久久免费观看 | 国产95在线 | 国产成人一区二区 | 成人在线视 | 精品视频一区二区三区 | 亚洲视频区 | 精品国产一区探花在线观看 | 色综合久 | 午夜不卡福利视频 | 日韩中文一区 | 国产高清在线精品 | 天天爱爱网 | 免费h视频| 日韩午夜在线观看 | 一级在线观看 | 国产精品伦一区二区三级视频 |