Skip to content

Commit 662e288

Browse files
committed
Replace Address IP Text Field with a NSComboBox to keep history of computed IP addresses
Saving history during App session is OK Does not save previous entered IP address Warning: does not check if the IP address is valid before saving it
1 parent c9ff303 commit 662e288

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

Base.lproj/MainMenu.xib

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>
@@ -164,7 +164,7 @@
164164
<customObject id="b7w-M5-ti7" userLabel="SubnetCalcAppDelegate" customClass="SubnetCalcAppDelegate" customModule="SubnetCalc" customModuleProvider="target">
165165
<connections>
166166
<outlet property="NSApp" destination="-2" id="wQ1-cQ-1kg"/>
167-
<outlet property="addrField" destination="614" id="TxW-DB-fIi"/>
167+
<outlet property="addrField" destination="Sgp-Di-Z4I" id="ayV-n5-gTg"/>
168168
<outlet property="bitsOnSlide" destination="710" id="N5K-tl-7ZU"/>
169169
<outlet property="classBinaryMap" destination="cg2-6d-5fs" id="KmO-au-Z39"/>
170170
<outlet property="classBitMap" destination="Okj-gg-NHb" id="pzE-Be-9mI"/>
@@ -222,7 +222,7 @@
222222
<window title="SubnetCalc" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="371">
223223
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
224224
<rect key="contentRect" x="0.0" y="0.0" width="670" height="694"/>
225-
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="900"/>
225+
<rect key="screenRect" x="0.0" y="0.0" width="1512" height="950"/>
226226
<value key="minSize" type="size" width="670" height="694"/>
227227
<view key="contentView" id="372">
228228
<rect key="frame" x="0.0" y="0.0" width="670" height="694"/>
@@ -1018,10 +1018,10 @@
10181018
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
10191019
<clipView key="contentView" id="Ay9-o5-UH1">
10201020
<rect key="frame" x="1" y="1" width="567" height="485"/>
1021-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1021+
<autoresizingMask key="autoresizingMask"/>
10221022
<subviews>
10231023
<tableView identifier="tabViewVLSM" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" headerView="SoM-fw-J5F" id="Xp5-Sj-frC">
1024-
<rect key="frame" x="0.0" y="0.0" width="884" height="457"/>
1024+
<rect key="frame" x="0.0" y="0.0" width="883.5" height="457"/>
10251025
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
10261026
<size key="intercellSpacing" width="3" height="2"/>
10271027
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -1127,7 +1127,7 @@
11271127
<autoresizingMask key="autoresizingMask"/>
11281128
</scroller>
11291129
<tableHeaderView key="headerView" wantsLayer="YES" id="SoM-fw-J5F">
1130-
<rect key="frame" x="0.0" y="0.0" width="884" height="28"/>
1130+
<rect key="frame" x="0.0" y="0.0" width="883.5" height="28"/>
11311131
<autoresizingMask key="autoresizingMask"/>
11321132
</tableHeaderView>
11331133
</scrollView>
@@ -1467,18 +1467,6 @@ CA
14671467
</tabViewItem>
14681468
</tabViewItems>
14691469
</tabView>
1470-
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="614">
1471-
<rect key="frame" x="171" y="654" width="329" height="22"/>
1472-
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
1473-
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" alignment="left" identifier="ipaddrfield" drawsBackground="YES" id="619">
1474-
<font key="font" metaFont="system"/>
1475-
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
1476-
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
1477-
</textFieldCell>
1478-
<connections>
1479-
<action selector="ipAddrEdit:" target="b7w-M5-ti7" id="FFd-Op-005"/>
1480-
</connections>
1481-
</textField>
14821470
<popUpButton identifier="exportbutton" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="737">
14831471
<rect key="frame" x="604" y="652" width="46" height="25"/>
14841472
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
@@ -1532,11 +1520,23 @@ CA
15321520
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
15331521
</textFieldCell>
15341522
</textField>
1523+
<comboBox verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Sgp-Di-Z4I">
1524+
<rect key="frame" x="171" y="651" width="332" height="25"/>
1525+
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
1526+
<comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" numberOfVisibleItems="10" id="Xfl-Op-pqt">
1527+
<font key="font" metaFont="system"/>
1528+
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
1529+
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
1530+
</comboBoxCell>
1531+
<connections>
1532+
<action selector="ipAddrEdit:" target="b7w-M5-ti7" id="xbF-0k-hpj"/>
1533+
</connections>
1534+
</comboBox>
15351535
</subviews>
15361536
</view>
15371537
<connections>
15381538
<outlet property="delegate" destination="b7w-M5-ti7" id="Y5C-zg-Ze5"/>
1539-
<outlet property="initialFirstResponder" destination="614" id="620"/>
1539+
<outlet property="initialFirstResponder" destination="Sgp-Di-Z4I" id="Dbp-Au-IpS"/>
15401540
</connections>
15411541
<point key="canvasLocation" x="84" y="281"/>
15421542
</window>

SubnetCalcAppDelegate.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
2626
//General UI elements
2727
//*******************
2828
@IBOutlet var window: NSWindow!
29-
@IBOutlet var addrField: NSTextField!
29+
@IBOutlet var addrField: NSComboBox!
3030
@IBOutlet var exportButton: NSPopUpButton!
3131
@IBOutlet var tabView: NSTabView!
3232
@IBOutlet var darkModeMenu: NSMenuItem!
@@ -1432,7 +1432,16 @@ class SubnetCalcAppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate,
14321432
*/
14331433
@IBAction func ipAddrEdit(_ sender: AnyObject)
14341434
{
1435-
self.calc(sender)
1435+
//print("ipAddrEdit action")
1436+
if ((sender as? NSTextField)?.stringValue) != nil {
1437+
if (sender.stringValue != "") {
1438+
if (addrField.indexOfItem(withObjectValue: sender.stringValue!) == NSNotFound) {
1439+
addrField.addItem(withObjectValue: sender.stringValue!)
1440+
}
1441+
self.calc(sender)
1442+
}
1443+
}
1444+
14361445
}
14371446

14381447
/**

0 commit comments

Comments
 (0)