Re: How to get array index with hierarchical listbox when using on mouse move

2017-03-02 Thread Arnaud de Montard via 4D_Tech

> Le 27 févr. 2017 à 15:27, Piotr Chabot Stadhouders via 4D_Tech 
> <4d_tech@lists.4d.com> a écrit :
> 
> Hi,
> 
> I want to use a hierarchical listbox with arrays
> When I am in the on mouse move event of the listbox, how can I determine 
> which element this is?
> I have found a tech tip where is explained how to get the row number.
> But how can I get from row number to array index?
> 
> Say I have 6 elements in a 1 parent and 1 child array, and there are 3 
> different parents, than the last row number returns 9, but there are only 6 
> elements in the arrays.

I put some code here

but… with a hierarchical listbox I'm afraid it's more complicated. 
I suppose an added array to keep the fold/unfold state may help. 

-- 
Arnaud de Montard




**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: How to get array index with hierarchical listbox when using on mouse move

2017-03-01 Thread Kirk Brooks via 4D_Tech
Piotr,

On Wed, Mar 1, 2017 at 9:19 AM, Piotr Chabot Stadhouders via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> @Kirk : I believe you are saying that the LISTBOX GET CELL POSITION
> command in your example returns 9 when we are in the last row, which is
> visually row 16 because of the hierarchy
>
​Correct. Because the arrays only contain 9 elements. The 'extra' rows are
merely visual sugar.

​I've never even tried to figure out how many visual rows are displayed in
a listbox. ​Is that what you need here?

-- 
Kirk Brooks
San Francisco, CA
===
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: How to get array index with hierarchical listbox when using on mouse move

2017-03-01 Thread Piotr Chabot Stadhouders via 4D_Tech
Hi Kirk, Tai,

Thanks for your responses, I will investigate further.

@Kirk : I believe you are saying that the LISTBOX GET CELL POSITION command in 
your example returns 9 when we are in the last row, which is visually row 16 
because of the hierarchy
@Tai : I used the highlight cell techtip with a "plain" listbox, but got into 
trouble when wanting to user a hierarchical listbox.

When using listboxes (I only use arrays) I use the listbox commands to get the 
actual column / row, and then use the returned row as element index.
But with the highlight tech tip, the returned row isn't equal to the array 
element because of the hierarchy. This is my actual problem.

Gr,

Piotr

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

RE: How to get array index with hierarchical listbox when using on mouse move

2017-02-28 Thread Tai Bui via 4D_Tech
Hi,

The issue with this problem is that the data is needed through the 'On Mouse 
Move' event which does not update the LISTBOX GET CELL POSITION command.

Instead you can create a method to get this information similarly to the 
methods described in the following Tech Tips:
http://kb.4d.com/assetid=77135
http://kb.4d.com/assetid=77119

The topic interested me and I created the method posted at the end which may 
help you. What I did was similar to the method described in the tech tip 
mentioned but instead utilized the LISTBOX GET CELL COORDINATES to determine 
which row is the mouse positioned over and more importantly figure out which 
rows are collapsed using the for loops. Hopefully this helps.

  // Util_LISTBOX_GET_MOUSE_HIER
  //
  // Details:
  //Returns the element details of a row
  //which has been hovered by the mouse cursor
  //
  // Parameters:
  //$1 - Pointer to Hierarchical List Box
  // Output:
  //$2 - Pointer To Pointer to Receive Pointer to Specific Array and Element
  //$3 - Pointer To Longint to Receive Column Number (aka Hier Array Level)
  //$4 - Pointer  To Longint to Receive Row Number (aka Array Element)

C_POINTER($1;$lbPtr)
C_POINTER($2;$resElem_p)
C_POINTER($3)
C_LONGINT($resCol_l)
C_POINTER($4)
C_LONGINT($resRow_l)

If (Count parameters>1)
ARRAY POINTER($hierVar_ap;0)

C_BOOLEAN($heir_B)

C_LONGINT($rowCount_l)
C_LONGINT($colCount_l)
C_LONGINT($mX;$mY;$mB)
C_LONGINT($lbBTrack)
C_LONGINT($rowStart_l)
C_LONGINT($lbL;$lbT;$lbR;$lbB)
C_LONGINT($tblNum;$fldNum)

C_TEXT($varName)
C_TEXT($fomula_t)

$lbPtr:=$1
$rowCount_l:=LISTBOX Get number of rows($lbPtr->)
LISTBOX GET HIERARCHY($lbPtr->;$hier_B;$hierVar_ap)
If($hier_B=True)
$colCount_l:=Size of array($hierVar_ap)
GET MOUSE($mX;$mY;$mB)

$resRow_l:=1
$resCol_l:=1
$lbTrack:=0
$rowStart_l:=1

For ($col_l;1;$colCount_l)
$lbBTrack:=0
For ($row_l;$rowStart_l;$rowCount_l)
LISTBOX GET CELL COORDINATES($lbPtr->;$col_l;$row_l;$lbL;$lbT;$lbR;$lbB)
Case of
: (($mY>$lbT) & ($mY<$lbB))
$resRow_l:=$row_l
$resCol_l:=$col_l
RESOLVE POINTER($hierVar_ap{$col_l};$varName;$tblNum;$fldNum)
$fomula_t:="$resElem_p:=->"+$varName+"{"+String($row_l)+}"
EXECUTE FORMULA($fomula_t)
$col_l:=$colCount_l
$row_l:=$rowCount_l
: ($mY>$lbB)
If ($lbB>$lbBTrack)
$lbBTrack:=$lbB
$rowStart_l:=$row_l
End if
: ($mY<$lbT)
$row_l:=$rowCount_l
End case
End for
End for
$2->:=$resElem_p
If(Count parameters>2)
$3->:=$resCol_l
$4->:=$resRow_l
End if
End if
End if

//End Method

Best Regards,
-Tai B.



**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: How to get array index with hierarchical listbox when using on mouse move

2017-02-28 Thread Kirk Brooks via 4D_Tech
Piortr,
You might be conflating a hierarchical list with a listbox.

The way you've described the listbox (if I understand it correctly) the
arrays in the listbox will be:

col 1   |  col 2  |  col 3
parent | child   | data
===
 p1 |  c1  | data1
 p1 |  c1  | data2
 p1 |  c1  | data3
 p1 |  c1  | data4
 p1 |  c1  | data5
 p1 |  c1  | data6
 p2 |  c1  | data7
 p3 |  c1  | data8
 p3 |  c2  | data9


which corresponds to a hierarchical list of:

p1 -
  c1 -
data1
data2
data3
data4
data5
data6
p2 -
  c1 -
data7
p3 -
  c1 -
data8
  c2 -
data9


You have to flatten the hierarchical data so that the parent, child and
data arrays are all the same size.

Making a listbox hierarchical doesn't change the nature of the data it
represents, it just changes the way the data are displayed. So you can
always use Listbox cell position to know what row is selected.

Did I answer the question you asked?


On Mon, Feb 27, 2017 at 6:27 AM, Piotr Chabot Stadhouders via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> Hi,
>
> I want to use a hierarchical listbox with arrays
> When I am in the on mouse move event of the listbox, how can I determine
> which element this is?
> I have found a tech tip where is explained how to get the row number.
> But how can I get from row number to array index?
>
> Say I have 6 elements in a 1 parent and 1 child array, and there are 3
> different parents, than the last row number returns 9, but there are only 6
> elements in the arrays.
>
> It must be something simple I've overlooked.
>
> Thanks in advance,
>
> Piotr
>
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **




-- 
Kirk Brooks
San Francisco, CA
===
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

How to get array index with hierarchical listbox when using on mouse move

2017-02-27 Thread Piotr Chabot Stadhouders via 4D_Tech
Hi,

I want to use a hierarchical listbox with arrays
When I am in the on mouse move event of the listbox, how can I determine which 
element this is?
I have found a tech tip where is explained how to get the row number.
But how can I get from row number to array index?

Say I have 6 elements in a 1 parent and 1 child array, and there are 3 
different parents, than the last row number returns 9, but there are only 6 
elements in the arrays.

It must be something simple I've overlooked.

Thanks in advance,

Piotr

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**