Saturday, November 18, 2017

#1 2016-07-14 08:42:26 am

tellboy
Member
Registered: 2005-06-23
Posts: 152

How to convert an integer into a NSView Ptr

I have a Ptr to an NSView derived in XOJO which is an Integer.

I want to print this NSView via an external script something like the following:

I believe the issue is with coercing tView(integer) so that the script recognises it as an NSView Ptr.

Is this the problem and how an it be overcome?

Applescript:


use framework "Foundation"
use framework "Cocoa"
use framework "AppKit"
use scripting additions

on run {tView}
   set tResult to printViewer(tView)
   return tResult
end run

on printViewer(tView)
   
   set tPrintOperation to current application's class "NSPrintOperation"'s printOperationWithView:tView
   
   tPrintOperation's runOperation
   
   set tResult to "ok"

   return tResult
   
end printViewer

Offline

 

#2 2016-07-14 01:35:47 pm

Mark FX
Member
From:: UK
Registered: 2011-08-12
Posts: 94

Re: How to convert an integer into a NSView Ptr

To my knowledge AppleScript Cannot work with pointers

You may have to pass the string in your Xojo App's view to the AppleScript, then use the NSPrintOperation class to print the string.
You can also use the NSPrintInfo class to format the page setup, e.g margins.

If your view has graphics and pictures, then things become more difficult, if not unpractical.

I used RB back in 2011, and even back then the support for AppleScript in RB was limited, and somewhat out of date.
With RB's successor Xojo, AppleScript support is even more out of date, which is a shame, as an ex VB programmer I
really liked Xojo, but the trouble is that it's support for external native code is poor, or your stuck with messy Declare statements which are hard to debug.

Is there not a Xojo class for printing ?

If not then I know there are plugin developers and vendors for Xojo, who might have something on offer for printing.

Regards Mark

Last edited by Mark FX (2016-07-14 01:38:36 pm)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)