Skip to content

Commit

Permalink
Merge pull request #1696 from slevenbits/slevenbits-tokenfield-autoco…
Browse files Browse the repository at this point in the history
…mplete-position

Fixed: token field autocomplete menu placed incorrectly.
  • Loading branch information
aljungberg committed Nov 29, 2012
2 parents 86b3024 + 4ef5dc8 commit 71b93a2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion AppKit/_CPAutocompleteMenu.j
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ var _CPAutocompleteMenuMaximumHeight = 307;
// TODO Track down why mystery constant is needed to allocate enough width. Scroll view insets?
}

var frameOrigin = [textField convertPoint:origin toView:nil],
var frameOrigin = [[textField window] convertBaseToGlobal:[textField convertPointToBase:origin]],
screenSize = [([CPPlatform isBrowser] ? [_menuWindow platformWindow] : [_menuWindow screen]) visibleFrame].size,
availableWidth = screenSize.width - frameOrigin.x,
availableHeight = screenSize.height - frameOrigin.y,
Expand Down
2 changes: 1 addition & 1 deletion Tests/Manual/AttachedSheet2/Resources/Window.cib

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion Tests/Manual/AttachedSheet2/Resources/Window.xib
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">33</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="393836098"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">226</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
Expand Down Expand Up @@ -1439,7 +1447,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">225</int>
<int key="maxID">226</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down
16 changes: 16 additions & 0 deletions Tests/Manual/AttachedSheet2/SheetWindowController.j
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,20 @@
[[_parentWindow contentView] setBackgroundColor:_savedColor];
}

- (CPArray)tokenField:(CPTokenField)aTokenField completionsForSubstring:(CPString)substring indexOfToken:(int)tokenIndex indexOfSelectedItem:(int)selectedIndex
{
var choices = ["aardvark", "baa", "caaing whale"],
r = [];

// Don't complete 'blank' - this would show all available matches which is excessive.
if (!substring)
return r;

for (var i = 0; i < choices.length; i++)
if (choices[i].toLowerCase().indexOf(substring.toLowerCase()) == 0)
r.push(choices[i]);

return r;
}

@end

0 comments on commit 71b93a2

Please sign in to comment.