Re: Does FTC have an equivalent of g.stringHeight for formatted text?

  • From: Jim Pitchford <jim@xxxxxxxxxxxxxxxx>
  • To: ftcdev@xxxxxxxxxxxxx
  • Date: Fri, 31 May 2013 16:10:19 -0500

OK, I think I have resolved this issue.

I was creating containerControls on the fly. Each container control includes an 
FTEditField canvas.

The problem was that I was trying to operate on the canvas before embedding the 
containerControl into the mainWindow.

Since the FTEditField.open event is where it is initialised, and the doc 
created, I was trying to operate on the doc, prior to its initialisation.

Solution was to create a new Container Control, Embed it within the Window and 
then operate on it.

Jim Pitchford
jim@xxxxxxxxxxxxxxxx



On 30 May 2013, at 17:55, Jim Pitchford <jim@xxxxxxxxxxxxxxxx> wrote:

> OK, but as it is subclassed from Canvas, I guess it does include Graphics.
> 
> Main point is what do I need to do to initialise FTEditField (or 
> FormattedText) so that the doc property is not nil?
> 
> Jim
> 
> 
> Jim Pitchford
> jim@xxxxxxxxxxxxxxxx
> 
> 
> 
> On 30 May 2013, at 16:55, Jym Morton <jymmorton@xxxxxxxxx> wrote:
> 
>> Would matter because TextField doesn't have a Graphics
>> Jym Morton
>> Toronto, ON
>> 
>> 
>> On Thu, May 30, 2013 at 4:09 PM, Jim Pitchford <jim@xxxxxxxxxxxxxxxx> wrote:
>> 
>>> Jim
>>> 
>>> Not sure that it matters either way - as once it is subclassed, it is what
>>> it is.
>>> 
>>> But, FTEdiitField is a subclass of FormattedText which is a subclass of
>>> Canvas.
>>> 
>>> Jim
>>> 
>>> 
>>> Jim Pitchford
>>> jim@xxxxxxxxxxxxxxxx
>>> 
>>> 
>>> 
>>> On 30 May 2013, at 14:33, Jym Morton <jymmorton@xxxxxxxxx> wrote:
>>> 
>>>> I don't have FTC on this computer, but isn't FTEditField a subclass of an
>>>> EditField and not a canvas?
>>>> Jym Morton
>>>> Toronto, ON
>>>> 
>>>> 
>>>> On Thu, May 30, 2013 at 2:48 PM, Jim Pitchford <jim@xxxxxxxxxxxxxxxx>
>>> wrote:
>>>> 
>>>>> Having another problem with FTC.
>>>>> 
>>>>> I have a containerControl in which I have a canvas with FTEditField as
>>> its
>>>>> super.
>>>>> 
>>>>> I now embed one or more of these containerControls into the mainWindow.
>>>>> 
>>>>> Now, when I try to call any of the getDoc functions, e.g.
>>>>> getDoc.getTotalPageLength I get a NilObjectException for getDoc.
>>> Checking
>>>>> shows that the doc property is empty.
>>>>> 
>>>>> What am I missing?
>>>>> 
>>>>> 
>>>>> 
>>>>> Jim Pitchford
>>>>> jim@xxxxxxxxxxxxxxxx
>>>>> 
>>>>> 
>>>>> 
>>>>> On 29 Apr 2013, at 18:24, Jim Pitchford <jim@xxxxxxxxxxxxxxxx> wrote:
>>>>> 
>>>>>> Ah, working now. I think it was something to do with margins when
>>>>> setting the edit mode. For some reason nI had it set to 5, setting to 0
>>>>> seems to work fine now.
>>>>>> 
>>>>>> Thanks Jym
>>>>>> 
>>>>>> Jim
>>>>>> 
>>>>>> 
>>>>>> Jim Pitchford
>>>>>> jim@xxxxxxxxxxxxxxxx
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> On 29 Apr 2013, at 18:13, Jym Morton <jymmorton@xxxxxxxxx> wrote:
>>>>>> 
>>>>>>> I started up the laptop and this worked fine for me
>>>>>>> Dim x As Integer = FormattedText1.getDoc.getTotalPageLength
>>>>>>> 
>>>>>>> 1 line was 33
>>>>>>> 2 lines were 58
>>>>>>> 
>>>>>>> Edit Mode and that's the call used to set the VScrollbar.
>>>>>>> 
>>>>>>> Jym Morton
>>>>>>> Toronto, ON
>>>>>>> 
>>>>>>> 
>>>>>>> On Mon, Apr 29, 2013 at 6:20 PM, Jim Pitchford <jim@xxxxxxxxxxxxxxxx>
>>>>> wrote:
>>>>>>> 
>>>>>>>> Jym
>>>>>>>> 
>>>>>>>> There's an FTC1.getDisplayHeight - but it seems to consistently come
>>>>> back
>>>>>>>> with a value of 136 when empty, 154 thereafter.
>>>>>>>> 
>>>>>>>> Jim Pitchford
>>>>>>>> jim@xxxxxxxxxxxxxxxx
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> On 29 Apr 2013, at 17:10, Jym Morton <jymmorton@xxxxxxxxx> wrote:
>>>>>>>> 
>>>>>>>>> I don't have it on this computer, I don't know that you want a
>>> getDoc
>>>>>>>> item,
>>>>>>>>> isn't there a getDisplayHeight or something like that?
>>>>>>>>> Jym Morton
>>>>>>>>> Toronto, ON
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Mon, Apr 29, 2013 at 6:00 PM, Jim Pitchford <
>>> jim@xxxxxxxxxxxxxxxx>
>>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>>> Jym
>>>>>>>>>> 
>>>>>>>>>> Thanks.
>>>>>>>>>> 
>>>>>>>>>> I've tried setting the mode to Edit - no impact.
>>>>>>>>>> Also I tried changing the super to FTTextField - still no impact.
>>>>>>>>>> 
>>>>>>>>>> I'm new to this control so any other advice appreciated.
>>>>>>>>>> 
>>>>>>>>>> Jim
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> Jim Pitchford
>>>>>>>>>> jim@xxxxxxxxxxxxxxxx
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> On 29 Apr 2013, at 16:39, Jym Morton <jymmorton@xxxxxxxxx> wrote:
>>>>>>>>>> 
>>>>>>>>>>> Sounds like you have it in the wrong mode as you don't want a
>>> page.
>>>>>>>>>>> Jym Morton
>>>>>>>>>>> Toronto, ON
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> On Mon, Apr 29, 2013 at 4:31 PM, Jim Pitchford <
>>>>> jim@xxxxxxxxxxxxxxxx>
>>>>>>>>>> wrote:
>>>>>>>>>>> 
>>>>>>>>>>>> Seth
>>>>>>>>>>>> 
>>>>>>>>>>>> I finally to to download and try out FTC - to see if I could set
>>>>> the
>>>>>>>>>>>> height of the control to match the content.
>>>>>>>>>>>> 
>>>>>>>>>>>> However, when I call getDoc.getTotalPageLength - I get a value
>>> of 0
>>>>>>>> (for
>>>>>>>>>>>> no text included) or 804 for 1 character or more.
>>>>>>>>>>>> 
>>>>>>>>>>>> So how can I adjust the height to fit the content like I would
>>> with
>>>>>>>>>>>> TextArea?
>>>>>>>>>>>> 
>>>>>>>>>>>> Jim
>>>>>>>>>>>> 
>>>>>>>>>>>> Unfortunately it always
>>>>>>>>>>>> Jim Pitchford
>>>>>>>>>>>> jim@xxxxxxxxxxxxxxxx
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> On 14 Aug 2012, at 14:23, Seth Verrinder <sethv@xxxxxxxxxxx>
>>>>> wrote:
>>>>>>>>>>>> 
>>>>>>>>>>>>> The FTDocument class has a function named getTotalPageLength
>>> that
>>>>>>>>>>>> returns the total height of the document.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> So to do what you want you'd need to do something like this
>>> (where
>>>>>>>> ftc
>>>>>>>>>>>> is your FormattedText control):
>>>>>>>>>>>>> 
>>>>>>>>>>>>> dim dTotalHeight as double
>>>>>>>>>>>>> dTotalHeight = ftc.getDoc.getTotalPageLength
>>>>>>>>>>>>> ftc.Height = dTotalHeight
>>>>>>>>>>>>> 
>>>>>>>>>>>>> You'll probably want to include a sensible maximum size. Since
>>>>>>>> there's
>>>>>>>>>>>> no fixed limit to the document size you could end up with a very
>>>>> large
>>>>>>>>>>>> control if a user does something unexpected like pasting in the
>>>>> entire
>>>>>>>>>>>> contents of a book or something.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>> Seth Verrinder
>>>>>>>>>>>>> BKeeney Software, Inc.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> On Aug 13, 2012, at 6:36 PM, Jim Pitchford wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> One of the limitations of RB's textArea is that you can't get
>>> the
>>>>>>>>>>>> stringheight of formatted text, unless it is all in one font and
>>>>> one
>>>>>>>>>> size.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Does FTC offer a way around that limitation so that I can set
>>> the
>>>>>>>> size
>>>>>>>>>>>> of the text area according to its formatted content?
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> JimFTC Website:
>>>>>>>>>> http://www.bkeeney.com/products/formatted-text-control
>>>>>>>>>>>>>> Set List Options (digest and vacation modes):
>>>>>>>>>>>> www.freelists.org/list/ftcdev
>>>>>>>>>>>>>> List Archive: www.freelists.org/archives/ftcdev
>>>>>>>>>>>>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>>>>>>>>>>> "unsubscribe" in the subject field.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> FTC Website:
>>>>> http://www.bkeeney.com/products/formatted-text-control
>>>>>>>>>>>>> Set List Options (digest and vacation modes):
>>>>>>>>>>>> www.freelists.org/list/ftcdev
>>>>>>>>>>>>> List Archive: www.freelists.org/archives/ftcdev
>>>>>>>>>>>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>>>>>>>>>>> "unsubscribe" in the subject field.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> FTC Website:
>>>>> http://www.bkeeney.com/products/formatted-text-control
>>>>>>>>>>>> Set List Options (digest and vacation modes):
>>>>>>>>>>>> www.freelists.org/list/ftcdev
>>>>>>>>>>>> List Archive: www.freelists.org/archives/ftcdev
>>>>>>>>>>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>>>>>>>>>>> "unsubscribe" in the subject field.
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> FTC Website:
>>> http://www.bkeeney.com/products/formatted-text-control
>>>>>>>>>>> Set List Options (digest and vacation modes):
>>>>>>>>>> www.freelists.org/list/ftcdev
>>>>>>>>>>> List Archive: www.freelists.org/archives/ftcdev
>>>>>>>>>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>>>>>>>>> "unsubscribe" in the subject field.
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> FTC Website:
>>> http://www.bkeeney.com/products/formatted-text-control
>>>>>>>>>> Set List Options (digest and vacation modes):
>>>>>>>>>> www.freelists.org/list/ftcdev
>>>>>>>>>> List Archive: www.freelists.org/archives/ftcdev
>>>>>>>>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>>>>>>>>> "unsubscribe" in the subject field.
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> FTC Website: http://www.bkeeney.com/products/formatted-text-control
>>>>>>>>> Set List Options (digest and vacation modes):
>>>>>>>> www.freelists.org/list/ftcdev
>>>>>>>>> List Archive: www.freelists.org/archives/ftcdev
>>>>>>>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>>>>>>> "unsubscribe" in the subject field.
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>>> FTC Website: http://www.bkeeney.com/products/formatted-text-control
>>>>>>>> Set List Options (digest and vacation modes):
>>>>>>>> www.freelists.org/list/ftcdev
>>>>>>>> List Archive: www.freelists.org/archives/ftcdev
>>>>>>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>>>>>>> "unsubscribe" in the subject field.
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> FTC Website: http://www.bkeeney.com/products/formatted-text-control
>>>>>>> Set List Options (digest and vacation modes):
>>>>> www.freelists.org/list/ftcdev
>>>>>>> List Archive: www.freelists.org/archives/ftcdev
>>>>>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>>>> "unsubscribe" in the subject field.
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> FTC Website: http://www.bkeeney.com/products/formatted-text-control
>>>>>> Set List Options (digest and vacation modes):
>>>>> www.freelists.org/list/ftcdev
>>>>>> List Archive: www.freelists.org/archives/ftcdev
>>>>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>>>> "unsubscribe" in the subject field.
>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>>> FTC Website: http://www.bkeeney.com/products/formatted-text-control
>>>>> Set List Options (digest and vacation modes):
>>>>> www.freelists.org/list/ftcdev
>>>>> List Archive: www.freelists.org/archives/ftcdev
>>>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>>>> "unsubscribe" in the subject field.
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>>> FTC Website: http://www.bkeeney.com/products/formatted-text-control
>>>> Set List Options (digest and vacation modes):
>>> www.freelists.org/list/ftcdev
>>>> List Archive: www.freelists.org/archives/ftcdev
>>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>> "unsubscribe" in the subject field.
>>>> 
>>>> 
>>>> 
>>> 
>>> FTC Website: http://www.bkeeney.com/products/formatted-text-control
>>> Set List Options (digest and vacation modes):
>>> www.freelists.org/list/ftcdev
>>> List Archive: www.freelists.org/archives/ftcdev
>>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with
>>> "unsubscribe" in the subject field.
>>> 
>>> 
>>> 
>> 
>> 
>> FTC Website: http://www.bkeeney.com/products/formatted-text-control
>> Set List Options (digest and vacation modes): www.freelists.org/list/ftcdev
>> List Archive: www.freelists.org/archives/ftcdev
>> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with "unsubscribe" 
>> in the subject field.
>> 
>> 
>> 
> 
> FTC Website: http://www.bkeeney.com/products/formatted-text-control
> Set List Options (digest and vacation modes): www.freelists.org/list/ftcdev
> List Archive: www.freelists.org/archives/ftcdev
> Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with "unsubscribe" in 
> the subject field.
> 
> 
> 

FTC Website: http://www.bkeeney.com/products/formatted-text-control
Set List Options (digest and vacation modes): www.freelists.org/list/ftcdev
List Archive: www.freelists.org/archives/ftcdev
Unsubscribe: Send email to ftcdev-request@xxxxxxxxxxxxx with "unsubscribe" in 
the subject field.


Other related posts: