久久久久久久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:獲取當前星期幾的值)
主站蜘蛛池模板: 欧美成人精品在线 | 欧美一级二级视频 | 亚洲欧美日韩精品久久亚洲区 | 日韩有码在线播放 | 黄色三级免费网站 | av大片| 女女百合av大片一区二区三区九县 | av一区二区三区 | 亚洲精品一区中文字幕乱码 | 凹凸日日摸日日碰夜夜 | 亚洲精品二三区 | 免费的网站www | 精品视频国产 | 国产欧美精品一区二区三区 | 亚洲一区 中文字幕 | 一区二区国产精品 | 日韩在线国产 | 久久精品aaa | 美女二区 | 在线一级片 | 色婷婷一区二区三区四区 | 蜜桃视频一区二区三区 | 久久亚洲一区二区三区四区 | 精品一二区 | 免费高潮视频95在线观看网站 | 国产传媒视频在线观看 | 久久看精品 | 九九久久免费视频 | 亚洲精品乱码8久久久久久日本 | 中文字幕 在线观看 | 伊人狠狠操 | 中文字幕av亚洲精品一部二部 | 蜜桃精品噜噜噜成人av | 99爱国产 | cao在线| 少妇精品亚洲一区二区成人 | 成人国产一区二区三区精品麻豆 | 一二区成人影院电影网 | 精品91久久 | 99精品久久99久久久久 | 国产99免费视频 |