[Q] Window pointer
[Q] Window pointer
Is there a way to get the window pointer?
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: [Q] Window pointer
If memory serves the windowID can be used in OS calls to address the window structure.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: [Q] Window pointer
Thanks.. Been a while since I've used RunRev/LiveCode and just started to play with LCB..
Re: [Q] Window pointer
okay, now how to use the windowID in LCB? I pass it from LiveScript as Integer but all the choices I've used for the Obj-C calls has either ended with LiveCode complaining about the data types being wrong or just crashing LiveCode..
I've used Integer, ObjcId and Pointer.. What should I be using?
I've used Integer, ObjcId and Pointer.. What should I be using?
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: [Q] Window pointer
I should have checked the LCB Guide before suggesting windowID. I know externals authors who've used it, but I don't know if it's available in LCB. If not, it would seem a valuable addition to the language.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: [Q] Window pointer
You can see an example in the source code of the browser widget .shaosean wrote:Is there a way to get the window pointer?
shiftLock happens
Re: [Q] Window pointer
I've used it before in an external, so I know it has worked..
I will check out the source of the browser widget..
Thanks to both of you
I will check out the source of the browser widget..
Thanks to both of you
Re: [Q] Window pointer
My bad.. I am trying to do this from a library and not a widget.. I did try the method used in the browser widget, but because there is no window control, the call fails "No current widget"
Guess it is time to file a feature request?
Code: Select all
library tk.shaosean.library.mac.test
use com.livecode.foreign
use com.livecode.widget
metadata version is "1.0.0"
metadata author is "shaosean.tk"
metadata title is "test"
public handler Test() returns nothing
if (the operating system is "mac") then
variable tParent as Pointer
MCWidgetGetMyStackNativeView(tParent)
end if
end handler
end library
Re: [Q] Window pointer
@shaosean : I take it you are wanting the NSWindow* for a stack? If so, what are you wanting to do with it?
The windowId property of stacks gives you the Cocoa window number, which you can convert to an NSWindow* by using the NSApp's windowWithWindowNumber class method (which you should be able to bind to using Obj-C FFI).
You can fetch the windowNumber from LCB using 'execute script'. As you are running in a library, you can do this at any point currently - there are no execute script restrictions in LCB libraries. (Even in a widget, you can't really get the windowNUmber of a widget's stack until Open - and OnOpen is not execution restricted so it is pretty much the same).
If you are wanting to embed a NSView you manage in a widget, then all you need to do is 'set my native layer to' in the widget. The property takes a raw pointer to the obj-c NSView object - which you need to fetch from an ObjcObject typed variable. e.g:
For widgets you should set the native layer in OnOpen, and then set it to nothing in OnClose.
The windowId property of stacks gives you the Cocoa window number, which you can convert to an NSWindow* by using the NSApp's windowWithWindowNumber class method (which you should be able to bind to using Obj-C FFI).
You can fetch the windowNumber from LCB using 'execute script'. As you are running in a library, you can do this at any point currently - there are no execute script restrictions in LCB libraries. (Even in a widget, you can't really get the windowNUmber of a widget's stack until Open - and OnOpen is not execution restricted so it is pretty much the same).
If you are wanting to embed a NSView you manage in a widget, then all you need to do is 'set my native layer to' in the widget. The property takes a raw pointer to the obj-c NSView object - which you need to fetch from an ObjcObject typed variable. e.g:
Code: Select all
variable tButtonView as ObjcObject
/* For a standard push button we need:
* type to be UIButtonTypeSystem = 1 */
put ObjC_UIButtonButtonWithType(1) into tButtonView
set my native layer to PointerFromObjcObject(tButtonView)
put tButtonView into mButtonView
Re: [Q] Window pointer
Thanks for the info. I'll play with it some more tonight.
Re: [Q] Window pointer
This is what I've got.. It doesn't throw any errors and it doesn't crash, but it doesn't seem to do anything..
Code: Select all
library tk.shaosean.library.mac.test
use com.livecode.foreign
use com.livecode.objc
metadata version is "1.0.0"
metadata author is "shaosean.tk"
metadata title is "test"
---------------------
private foreign handler NSApplicationSharedApplication() returns ObjcId binds to "objc:NSApplication.+sharedApplication"
private foreign handler NSApplicationWindowWithWindowNumber(in sharedApplication as ObjcId, in windowNumber as Integer) returns ObjcId binds to "objc:NSApplication.-windowWithWindowNumber:"
private foreign handler NSWindowToggleFullScreen(in aNSWindow as ObjcID) returns nothing binds to "objc:NSWindow.-toggleFullScreen:"
---------------------
public handler Test(windowID as Integer) returns nothing
if the operating system is "mac" then
unsafe
variable NSSharedApplication as ObjcId
put NSApplicationSharedApplication() into NSSharedApplication
variable aNSWindow as ObjcID
put NSApplicationWindowWithWindowNumber(NSSharedApplication, windowID) into aNSWindow
NSWindowToggleFullScreen(aNSWindow)
end unsafe
end if
end handler
end library
-
- Posts: 626
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: [Q] Window pointer
Maybe a key has to be set in the (LiveCode IDE or Standalone) Application's plist for a certain PresentationMode so the System Knows the app can put into full-screen? Just a guess.
https://developer.apple.com/library/con ... 431-113616
https://developer.apple.com/library/con ... 431-113616
Re: [Q] Window pointer
Good idea, but for full screen, it's not needed.. The presentation keys are for doing kiosk applications (I browsed that linked page just to make sure I didn't miss anything)
For now, I'll wait until a new release of LiveCode comes out before playing with LCB..
For now, I'll wait until a new release of LiveCode comes out before playing with LCB..
Re: [Q] Window pointer
I got the full screen thing working, but only as a widget, which doesn't really make too much sense.. Would still like to get it working with the windowID, or some way of getting the NSWindow pointer without having to use a widget..
Re: [Q] Window pointer
Probably, I do not understand how to use this feature, but
What is the difference between using fullscreenmodes and
windows pointers?
Al
What is the difference between using fullscreenmodes and
windows pointers?
Al