Achim, have you tried this yourself? 

I think it is not possible in 4D Write PRO v17 to select 1 or more cells in a 
table and then be able to get the cells reference by code.

Just follow this scenario:

- the user creates a table in 4D Write PRO (by clicking a button containing the 
code WP Insert Table)
- Basically, the developer provides a dialog to ask for the number of columns 
and rows, and eventually column width, background color etc.
- the table will be created in the 4D Write PRO document, where the user can 
add content.

Now, the user wants to change attributes of the cells, or columns. i.e. width, 
color, borders. In order to do that (in code), the developer needs to know 
which cells have been selected.

In the table, the user can select 1 or more cells, but here’s the problem: how 
to find out which cell(s) have been selected?

WP get selection will return an object with a ’start’, ‘end’ and ’type’ 
attribute. Type is always = 0, start and end e.g. 32,40 do not give any clue as 
to which cell is selected.
Interestingly, WP Create table range returns exactly the same result, but type 
= 4

‘WP Get position': nothing that can be used: While the user has selected cells 
1 and 2, we get this result:
‘column’ = 1
‘line’ = 3
‘page’ = 1
‘position’ =1

'WP GET ELEMENTS' will return a collection, where the table object can indeed 
be found, but still no information about which cell or cells are selected.
‘WP Table Get Cells' will create a new range containing the specified cells, 
but NOT provide information about which cells are actually selected.


Rudy Mortier
Two Way Communications bvba 



> On 11 Jul 2018, at 19:16, Keisuke Miyako via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> a table reference can be obtained from
> 
> WP Create table range
> http://doc.4d.com/4Dv17/4D/17/WP-Create-table-range.301-3703205.en.html
> 
> WP Get elements
> http://doc.4d.com/4Dv17/4D/17/WP-Get-elements.301-3703212.en.html
> 
> or
> 
> WP Get element by ID
> http://doc.4d.com/4Dv17/4D/17/WP-Get-element-by-ID.301-3703233.en.html
> 
> in v16/R, I believe it is only be possible to obtain such a reference
> immediately following creation (WP Insert table)
> 
> ---
> 
> the way I understand it is that a write pro document is a combination of 
> range (of text) and other objects that do not fit in any particular range (of 
> text). such objects are also referred to as a "range object" in the language 
> (table, row, column, anchored picture, etc)
> 
> http://doc.4d.com/4Dv17/4D/17/Accessing-document-contents-by-programming.300-3726304.en.html#3507530
> 
> commands such as WP SELECT work on range of text.
> 
> some commands like WP Get selection works on a range of text or a "range 
> object".
> (result.type tells which)
> 
> 2018/07/12 0:57、Two Way Communications via 4D_Tech 
> <4d_tech@lists.4d.com<mailto:4d_tech@lists.4d.com>> のメール:
> So, what if the user has created a table (through a method), and now want to 
> select a cell in that table and change it’s background color, or it’s width?
> 
> 
> 
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **********************************************************************

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

Reply via email to