|
Error converting object pointer to type P7TextBox |
Posted by Nick on Oct-13-2016 23:29 |
|
Using the Ruby version of ChartDirector 5.1.1 on both the linux 64-bit version and the OSX version, I'm running into `TypeError: Error converting object pointer to type P7TextBox` when trying to set attributes to customize a textbox.
We have a method that takes a table, coordinates, and a string to add a textbox to the table:
```
def add_table_label(table, x, y, string)
label = table.setText(y,x,string)
label.setFontStyle('arialbd.ttf')
label.setFontSize(10)
label.setFontColor(0x666666)
label.setMargin2(5, 5, 2, 2)
label.setBackground(-1, -1, 0)
label.setMaxWidth(100)
end
```
```
>> table.inspect
=> "#<ChartDirector::CDMLTable:0x007fd2b5535900 @this="$$pointer$$P9CDMLTable@7fd2ada63ac0">"
>> label.inspect
=> "#<ChartDirector::TextBox:0x007fd2b95e5798 @this="$$pointer$$P7TextBox@0">"
```
The error occurs on the line:
```
label.setFontStyle('arialbd.ttf')
```
But when the line is removed, the next setter causes the same error, and each one after that does the same.
Can you help me understand what I'm doing wrong? Based on the docs, I had expected this to work. |
Re: Error converting object pointer to type P7TextBox |
Posted by Peter Kwan on Oct-14-2016 00:13 |
|
Hi Nick,
Is it possible the table cell does not exist?
The CDMLTable.setText sets the text of a table cell. If there is no such cell, it cannot return a TextBox object, so any attempt to use the returned object will cause error.
If the CDMLTable is created by XYChart.addTable, then your code should have supplied the number of columns and rows in the table. For example, if there are 3 columns and 4 rows, the col number should be 0, 1, 2, and the row number should be 0, 1, 2, 3. Note that the column and row numbers starts from 0.
I also noted that your code uses setText(y, x, string). Should it be addText(x, y, string)? (It depends on what do x and y mean in your code.)
If you need further help, would you mind to clarify how the CDMLTable is obtained (is it added using XYChart.addTable, or obtained using Axis.makeLabelTable)?
Regards
Peter Kwan |
Re: Error converting object pointer to type P7TextBox |
Posted by Nick on Oct-14-2016 02:18 |
|
Hi Peter, thanks for the quick response!
The problem was me going out of bounds on the table, as you suggested!
Thanks again,
-- Nick |
|