Datawindow dragdrop事件并不总是在放置位置返回对控件的引用

问题描述 投票:0回答:2

简而言之,我需要在拖动控件后删除控件的对象类型上建立一些窗口行为。只要目标上的目标控件是列,但是如果它是任何其他对象,则这一切都很好。

假设我有一个包含两列和一个矩形的数据窗口。我们分别称它们为c_1,c_2和r_1。

我拖动c_1并将其放在c_2上:

dwo.name = c_2
dwo.type = column

这很好,而且正是我期望的行为。

我拖动c_1并将其放在r_1上:

dwo.name = datawindow
dwo.type = datawindow

返回对数据窗口本身的引用。这太宽泛了,无法用作构建任何有意义的东西的基础,至少在我的情况下如此。

在测试中,似乎我不能让dragdrop在放置位置返回对控件的引用,除非它是一列。这是打算,还是我的环境出了问题?如果我需要基于dwo.type或dwo.name的值的窗口行为,我该如何解决这个问题?

powerbuilder datawindow
2个回答
0
投票

使用函数GetObjectAtPointer

它将允许您确切地知道用户丢弃了什么对象。

它返回一个objectname~trow形式的字符串,您必须解析该字符串以确定您需要的内容。


0
投票

一种方法是检查指针的X和Y坐标与数据窗口中的控件数组。

在数据窗口的事件中,您可以获得如下对象列表:

is_selected_controls = is_null //both of these are string arrays
ls_objects = this.Describe( 'DataWindow.Objects')
ls_objects = ls_objects + '~t'
ll_pos = pos(ls_objects, '~t')
ll_orig_pos = 1

然后遍历数组并获得每个控件X,W,Width,Height

DO WHILE ll_pos > 0
    ls_object = mid(ls_objects, ll_orig_pos, ll_pos -ll_orig_pos)
    IF describe(ls_object + '.type') = 'line' THEN
        ls_x = this.Describe(ls_object + '.X1')
        ls_y = this.Describe(ls_object + '.Y1')
        ls_h = this.Describe(ls_object + '.Y2')
        ls_w = this.Describe(ls_object + '.X2')

    ELSE
        ls_x = this.Describe(ls_object + '.X')
        ls_y = this.Describe(ls_object + '.Y')
        ls_h = this.Describe(ls_object + '.height')
        ls_w = this.Describe(ls_object + '.width')
    END IF
    // compare the X,Y of the pointer to control position to see if it's
    // on the control, if it is exit the loop and do whatever...

    ll_orig_pos = ll_pos + 1
    ll_pos = pos(ls_objects, '~t', ll_orig_pos)
LOOP
© www.soinside.com 2019 - 2024. All rights reserved.