Greg_O
(Greg O)
March 5, 2023, 3:08am
1
I’m working on implementing a method on a subclass of NSView and am having trouble getting the type encoding set correctly. If anyone is familiar with this, I’d love some help:
The method I’m implementing is:
- (void)drawRect:(NSRect) dirtyRect;
The encoding I’m currently looking at is:
v@:{NSRect={NSPoint=ff}{NSSize=ff}}
I’ve also tried
v@:{NSRect=ffff}
The signature of the Xojo method is:
Shared Sub SharedDrawRect(sender as ptr, sel as ptr, rect as NSRect)
And NSRect is a structure which contains an NSPoint and an NSPoint, both of which contain two CGFloats.
Any thoughts?
Rick_A
(Rick A)
March 5, 2023, 11:12am
2
In a test here (online, not real machine) I see dd not ff.
2023-03-05 11:07:18.305 a.out[6682:6682] {_NSRect={_NSPoint=dd}{_NSSize=dd}}
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSLog(@"%s", @encode(NSRect));
return 0;
}
JulianS
(JulianS)
March 5, 2023, 11:55am
3
They have been doubles since 10.5 but are still floats on watchOS according to the apple docs.
Greg_O
(Greg O)
March 5, 2023, 12:09pm
4
Excellent @Rick_A , could you give me the URL for that tool?
Edit: nm, I found it. Was just challenging on my phone.
Greg_O
(Greg O)
March 5, 2023, 1:29pm
6
Thanks guys. I’ll try this later today.
1 Like
Private Shared Function TargetClass() As ptr
static targetID as ptr
if targetID = Nil then
using UIKit
dim methods() as TargetClassMethodHelper
//detecting shaking
methods.Append new TargetClassMethodHelper("canBecomeFirstResponder", AddressOf impl_canBecomeFirstResponder, "B@:")
methods.Append new TargetClassMethodHelper("motionBegan:withEvent:", AddressOf impl_motionBegan, "v@:i@")
methods.Append new TargetClassMethodHelper("motionEnded:withEvent:", AddressOf impl_motionEnded, "v@:i@")
//drawing/Paint event
#if Target32Bit
methods.Append new TargetClassMethodHelper("drawRect:", AddressOf impl_drawRect32, "v@:{NSRect=ffff}")
#Elseif Target64Bit
methods.Append new TargetClassMethodHelper("drawRect:", AddressOf impl_drawRect64, "v@:{NSRect=ffff}")
#Endif
//touches
methods.Append new TargetClassMethodHelper("touchesBegan:withEvent:", AddressOf impl_touchesBegan, "v@:@@")
methods.Append new TargetClassMethodHelper("touchesMoved:withEvent:", AddressOf impl_touchesMoved, "v@:@@")
methods.Append new TargetClassMethodHelper("touchesEnded:withEvent:", AddressOf impl_touchesEnded, "v@:@@")
This used to work. Haven’t tried on recent iOS but I assume it’s fine
Rick A:
iOS included?
If I remember correctly, Xojo can’t build watchOS apps.
Rick_A
(Rick A)
March 5, 2023, 5:24pm
10
I questioned iOS, Xojo can build for it. Did iOS also maintain floats?
Gotcha, that wasn’t entirely clear, sorry.
Greg_O
(Greg O)
March 5, 2023, 5:41pm
13
I’m really only interested in NSView on macOS at the moment so I think this’ll do what I need. Just haven’t had a chance to try it out yet.
I’ve used “{NSRect}
” for various functions as arguments and return values.