Skip to content

Commit 8b41a42

Browse files
author
Peter Argany
committed
Moved FBPrintWindow functionality to a flag on pviews
1 parent 5dc5776 commit 8b41a42

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

commands/FBPrintCommands.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,27 @@ def options(self):
5252
return [
5353
fb.FBCommandArgument(short='-u', long='--up', arg='upwards', boolean=True, default=False, help='Print only the hierarchy directly above the view, up to its window.'),
5454
fb.FBCommandArgument(short='-d', long='--depth', arg='depth', type='int', default="0", help='Print only to a given depth. 0 indicates infinite depth.'),
55+
fb.FBCommandArgument(short='-w', long='--window', arg='window', type='int', default="0", help='Specify the window to print a description of. Check which windows exist with "po (id)[[UIApplication sharedApplication] windows]".'),
5556
]
5657

5758
def args(self):
5859
return [ fb.FBCommandArgument(arg='aView', type='UIView*/NSView*', help='The view to print the description of.', default='__keyWindow_dynamic__') ]
5960

6061
def run(self, arguments, options):
6162
maxDepth = int(options.depth)
63+
window = int(options.window)
6264
isMac = runtimeHelpers.isMacintoshArch()
6365

64-
if arguments[0] == '__keyWindow_dynamic__':
65-
arguments[0] = '(id)[[UIApplication sharedApplication] keyWindow]'
66-
66+
if window > 0:
67+
if isMac:
68+
arguments[0] = '(id)[[[[NSApplication sharedApplication] windows] objectAtIndex:' + str(window) + '] contentView]'
69+
else:
70+
arguments[0] = '(id)[[[UIApplication sharedApplication] windows] objectAtIndex:' + str(window) + ']'
71+
elif arguments[0] == '__keyWindow_dynamic__':
6772
if isMac:
6873
arguments[0] = '(id)[[[[NSApplication sharedApplication] windows] objectAtIndex:0] contentView]'
74+
else:
75+
arguments[0] = '(id)[[UIApplication sharedApplication] keyWindow]'
6976

7077
if options.upwards:
7178
view = arguments[0]

0 commit comments

Comments
 (0)