diff --git a/Limelight/Images.xcassets/DownArrowIcon.imageset/Contents.json b/Limelight/Images.xcassets/DownArrowIcon.imageset/Contents.json new file mode 100644 index 00000000..29227e6b --- /dev/null +++ b/Limelight/Images.xcassets/DownArrowIcon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "DownIcon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/DownArrowIcon.imageset/DownIcon.png b/Limelight/Images.xcassets/DownArrowIcon.imageset/DownIcon.png new file mode 100644 index 00000000..100f99ea Binary files /dev/null and b/Limelight/Images.xcassets/DownArrowIcon.imageset/DownIcon.png differ diff --git a/Limelight/Images.xcassets/F10Icon.imageset/Contents.json b/Limelight/Images.xcassets/F10Icon.imageset/Contents.json new file mode 100644 index 00000000..9f1b3238 --- /dev/null +++ b/Limelight/Images.xcassets/F10Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F10Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F10Icon.imageset/F10Icon.png b/Limelight/Images.xcassets/F10Icon.imageset/F10Icon.png new file mode 100644 index 00000000..9a988138 Binary files /dev/null and b/Limelight/Images.xcassets/F10Icon.imageset/F10Icon.png differ diff --git a/Limelight/Images.xcassets/F11Icon.imageset/Contents.json b/Limelight/Images.xcassets/F11Icon.imageset/Contents.json new file mode 100644 index 00000000..9bfc9e29 --- /dev/null +++ b/Limelight/Images.xcassets/F11Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F11Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F11Icon.imageset/F11Icon.png b/Limelight/Images.xcassets/F11Icon.imageset/F11Icon.png new file mode 100644 index 00000000..33ea6a43 Binary files /dev/null and b/Limelight/Images.xcassets/F11Icon.imageset/F11Icon.png differ diff --git a/Limelight/Images.xcassets/F12Icon.imageset/Contents.json b/Limelight/Images.xcassets/F12Icon.imageset/Contents.json new file mode 100644 index 00000000..f1e32fc2 --- /dev/null +++ b/Limelight/Images.xcassets/F12Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F12Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F12Icon.imageset/F12Icon.png b/Limelight/Images.xcassets/F12Icon.imageset/F12Icon.png new file mode 100644 index 00000000..8e72ff38 Binary files /dev/null and b/Limelight/Images.xcassets/F12Icon.imageset/F12Icon.png differ diff --git a/Limelight/Images.xcassets/F1Icon.imageset/Contents.json b/Limelight/Images.xcassets/F1Icon.imageset/Contents.json new file mode 100644 index 00000000..2448f585 --- /dev/null +++ b/Limelight/Images.xcassets/F1Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F1Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F1Icon.imageset/F1Icon.png b/Limelight/Images.xcassets/F1Icon.imageset/F1Icon.png new file mode 100644 index 00000000..519c19e4 Binary files /dev/null and b/Limelight/Images.xcassets/F1Icon.imageset/F1Icon.png differ diff --git a/Limelight/Images.xcassets/F2Icon.imageset/Contents.json b/Limelight/Images.xcassets/F2Icon.imageset/Contents.json new file mode 100644 index 00000000..ff683fd5 --- /dev/null +++ b/Limelight/Images.xcassets/F2Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F2Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F2Icon.imageset/F2Icon.png b/Limelight/Images.xcassets/F2Icon.imageset/F2Icon.png new file mode 100644 index 00000000..fdb1ab85 Binary files /dev/null and b/Limelight/Images.xcassets/F2Icon.imageset/F2Icon.png differ diff --git a/Limelight/Images.xcassets/F3Icon.imageset/Contents.json b/Limelight/Images.xcassets/F3Icon.imageset/Contents.json new file mode 100644 index 00000000..e841cc9b --- /dev/null +++ b/Limelight/Images.xcassets/F3Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F3Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F3Icon.imageset/F3Icon.png b/Limelight/Images.xcassets/F3Icon.imageset/F3Icon.png new file mode 100644 index 00000000..818dc4e2 Binary files /dev/null and b/Limelight/Images.xcassets/F3Icon.imageset/F3Icon.png differ diff --git a/Limelight/Images.xcassets/F4Icon.imageset/Contents.json b/Limelight/Images.xcassets/F4Icon.imageset/Contents.json new file mode 100644 index 00000000..0baedb7d --- /dev/null +++ b/Limelight/Images.xcassets/F4Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F4Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F4Icon.imageset/F4Icon.png b/Limelight/Images.xcassets/F4Icon.imageset/F4Icon.png new file mode 100644 index 00000000..046d0c78 Binary files /dev/null and b/Limelight/Images.xcassets/F4Icon.imageset/F4Icon.png differ diff --git a/Limelight/Images.xcassets/F5Icon.imageset/Contents.json b/Limelight/Images.xcassets/F5Icon.imageset/Contents.json new file mode 100644 index 00000000..32f0d027 --- /dev/null +++ b/Limelight/Images.xcassets/F5Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F5Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F5Icon.imageset/F5Icon.png b/Limelight/Images.xcassets/F5Icon.imageset/F5Icon.png new file mode 100644 index 00000000..ca011f00 Binary files /dev/null and b/Limelight/Images.xcassets/F5Icon.imageset/F5Icon.png differ diff --git a/Limelight/Images.xcassets/F6Icon.imageset/Contents.json b/Limelight/Images.xcassets/F6Icon.imageset/Contents.json new file mode 100644 index 00000000..44d5bf27 --- /dev/null +++ b/Limelight/Images.xcassets/F6Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F6Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F6Icon.imageset/F6Icon.png b/Limelight/Images.xcassets/F6Icon.imageset/F6Icon.png new file mode 100644 index 00000000..d492f827 Binary files /dev/null and b/Limelight/Images.xcassets/F6Icon.imageset/F6Icon.png differ diff --git a/Limelight/Images.xcassets/F7Icon.imageset/Contents.json b/Limelight/Images.xcassets/F7Icon.imageset/Contents.json new file mode 100644 index 00000000..d9c9d8b9 --- /dev/null +++ b/Limelight/Images.xcassets/F7Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F7Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F7Icon.imageset/F7Icon.png b/Limelight/Images.xcassets/F7Icon.imageset/F7Icon.png new file mode 100644 index 00000000..463ed514 Binary files /dev/null and b/Limelight/Images.xcassets/F7Icon.imageset/F7Icon.png differ diff --git a/Limelight/Images.xcassets/F8Icon.imageset/Contents.json b/Limelight/Images.xcassets/F8Icon.imageset/Contents.json new file mode 100644 index 00000000..86b6836f --- /dev/null +++ b/Limelight/Images.xcassets/F8Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F8Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F8Icon.imageset/F8Icon.png b/Limelight/Images.xcassets/F8Icon.imageset/F8Icon.png new file mode 100644 index 00000000..f05f4ed9 Binary files /dev/null and b/Limelight/Images.xcassets/F8Icon.imageset/F8Icon.png differ diff --git a/Limelight/Images.xcassets/F9Icon.imageset/Contents.json b/Limelight/Images.xcassets/F9Icon.imageset/Contents.json new file mode 100644 index 00000000..8ad91783 --- /dev/null +++ b/Limelight/Images.xcassets/F9Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "F9Icon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/F9Icon.imageset/F9Icon.png b/Limelight/Images.xcassets/F9Icon.imageset/F9Icon.png new file mode 100644 index 00000000..adfb714a Binary files /dev/null and b/Limelight/Images.xcassets/F9Icon.imageset/F9Icon.png differ diff --git a/Limelight/Images.xcassets/LeftArrowIcon.imageset/Contents.json b/Limelight/Images.xcassets/LeftArrowIcon.imageset/Contents.json new file mode 100644 index 00000000..ca143c25 --- /dev/null +++ b/Limelight/Images.xcassets/LeftArrowIcon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "LeftIcon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/LeftArrowIcon.imageset/LeftIcon.png b/Limelight/Images.xcassets/LeftArrowIcon.imageset/LeftIcon.png new file mode 100644 index 00000000..932b8976 Binary files /dev/null and b/Limelight/Images.xcassets/LeftArrowIcon.imageset/LeftIcon.png differ diff --git a/Limelight/Images.xcassets/RightArrowIcon.imageset/Contents.json b/Limelight/Images.xcassets/RightArrowIcon.imageset/Contents.json new file mode 100644 index 00000000..283f5ad8 --- /dev/null +++ b/Limelight/Images.xcassets/RightArrowIcon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "RightIcon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/RightArrowIcon.imageset/RightIcon.png b/Limelight/Images.xcassets/RightArrowIcon.imageset/RightIcon.png new file mode 100644 index 00000000..7294a5b5 Binary files /dev/null and b/Limelight/Images.xcassets/RightArrowIcon.imageset/RightIcon.png differ diff --git a/Limelight/Images.xcassets/UpArrowIcon.imageset/Contents.json b/Limelight/Images.xcassets/UpArrowIcon.imageset/Contents.json new file mode 100644 index 00000000..6d3566f4 --- /dev/null +++ b/Limelight/Images.xcassets/UpArrowIcon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "UpIcon.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Limelight/Images.xcassets/UpArrowIcon.imageset/UpIcon.png b/Limelight/Images.xcassets/UpArrowIcon.imageset/UpIcon.png new file mode 100644 index 00000000..d70b1e12 Binary files /dev/null and b/Limelight/Images.xcassets/UpArrowIcon.imageset/UpIcon.png differ diff --git a/Limelight/Input/StreamView.m b/Limelight/Input/StreamView.m index 8891a9bc..304bfca8 100644 --- a/Limelight/Input/StreamView.m +++ b/Limelight/Input/StreamView.m @@ -363,20 +363,64 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { keyInputField.text = @"0"; #if !TARGET_OS_TV // Prepare the toolbar above the keyboard for more options - UIToolbar *customToolbarView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 44)]; + const CGFloat BUTTON_WIDTH = 88; + const CGFloat BUTTON_HEIGHT = 44; + // Function key count except for the `Done` button. `Done` button is not in the scrollView, but is always on top. + const CGFloat FUNCTION_KEY_COUNT = 23; + const CGFloat TOOLBAR_WIDTH = BUTTON_WIDTH * FUNCTION_KEY_COUNT; - UIBarButtonItem *doneBarButton = [self createButtonWithImageNamed:@"DoneIcon.png" backgroundColor:[UIColor clearColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x00 isToggleable:NO]; - UIBarButtonItem *windowsBarButton = [self createButtonWithImageNamed:@"WindowsIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x5B isToggleable:YES]; - UIBarButtonItem *tabBarButton = [self createButtonWithImageNamed:@"TabIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x09 isToggleable:NO]; - UIBarButtonItem *shiftBarButton = [self createButtonWithImageNamed:@"ShiftIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0xA0 isToggleable:YES]; - UIBarButtonItem *escapeBarButton = [self createButtonWithImageNamed:@"EscapeIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x1B isToggleable:NO]; - UIBarButtonItem *controlBarButton = [self createButtonWithImageNamed:@"ControlIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0xA2 isToggleable:YES]; - UIBarButtonItem *altBarButton = [self createButtonWithImageNamed:@"AltIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0xA4 isToggleable:YES]; - UIBarButtonItem *deleteBarButton = [self createButtonWithImageNamed:@"DeleteIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x2E isToggleable:NO]; + // Function toolbar + UIBarButtonItem *doneBarButton = [self createButtonWithImageNamed:@"DoneIcon.png" backgroundColor:[UIColor clearColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x00 isToggleable:NO]; + UIBarButtonItem *windowsBarButton = [self createButtonWithImageNamed:@"WindowsIcon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x5B isToggleable:YES]; + UIBarButtonItem *escapeBarButton = [self createButtonWithImageNamed:@"EscapeIcon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x1B isToggleable:NO]; + UIBarButtonItem *tabBarButton = [self createButtonWithImageNamed:@"TabIcon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x09 isToggleable:NO]; + UIBarButtonItem *shiftBarButton = [self createButtonWithImageNamed:@"ShiftIcon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0xA0 isToggleable:YES]; + UIBarButtonItem *controlBarButton = [self createButtonWithImageNamed:@"ControlIcon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0xA2 isToggleable:YES]; + UIBarButtonItem *altBarButton = [self createButtonWithImageNamed:@"AltIcon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0xA4 isToggleable:YES]; + UIBarButtonItem *deleteBarButton = [self createButtonWithImageNamed:@"DeleteIcon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x2E isToggleable:NO]; + UIBarButtonItem *leftBarButton = [self createButtonWithImageNamed:@"LeftArrowIcon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x25 isToggleable:NO]; + UIBarButtonItem *downBarButton = [self createButtonWithImageNamed:@"DownArrowIcon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x28 isToggleable:NO]; + UIBarButtonItem *upBarButton = [self createButtonWithImageNamed:@"UpArrowIcon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x26 isToggleable:NO]; + UIBarButtonItem *rightBarButton = [self createButtonWithImageNamed:@"RightArrowIcon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x27 isToggleable:NO]; + UIBarButtonItem *f1BarButton = [self createButtonWithImageNamed:@"F1Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x70 isToggleable:NO]; + UIBarButtonItem *f2BarButton = [self createButtonWithImageNamed:@"F2Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x71 isToggleable:NO]; + UIBarButtonItem *f3BarButton = [self createButtonWithImageNamed:@"F3Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x72 isToggleable:NO]; + UIBarButtonItem *f4BarButton = [self createButtonWithImageNamed:@"F4Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x73 isToggleable:NO]; + UIBarButtonItem *f5BarButton = [self createButtonWithImageNamed:@"F5Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x74 isToggleable:NO]; + UIBarButtonItem *f6BarButton = [self createButtonWithImageNamed:@"F6Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x75 isToggleable:NO]; + UIBarButtonItem *f7BarButton = [self createButtonWithImageNamed:@"F7Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x76 isToggleable:NO]; + UIBarButtonItem *f8BarButton = [self createButtonWithImageNamed:@"F8Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x77 isToggleable:NO]; + UIBarButtonItem *f9BarButton = [self createButtonWithImageNamed:@"F9Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x78 isToggleable:NO]; + UIBarButtonItem *f10BarButton = [self createButtonWithImageNamed:@"F10Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x79 isToggleable:NO]; + UIBarButtonItem *f11BarButton = [self createButtonWithImageNamed:@"F11Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x7A isToggleable:NO]; + UIBarButtonItem *f12BarButton = [self createButtonWithImageNamed:@"F12Icon.png" backgroundColor:[UIColor blackColor] buttonWidth: BUTTON_WIDTH target:self action:@selector(toolbarButtonClicked:) keyCode:0x7B isToggleable:NO]; UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; + // Removes unwanted space between buttons + UIBarButtonItem *negativeSeperator = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; + negativeSeperator.width = -1; - [customToolbarView setItems:[NSArray arrayWithObjects:doneBarButton, windowsBarButton, escapeBarButton, tabBarButton, shiftBarButton, controlBarButton, altBarButton, deleteBarButton, flexibleSpace, nil]]; - keyInputField.inputAccessoryView = customToolbarView; + UIToolbar * functionToolbarView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, BUTTON_HEIGHT)]; + functionToolbarView.autoresizingMask = UIViewAutoresizingNone; + [functionToolbarView setItems:[NSArray arrayWithObjects:negativeSeperator, windowsBarButton, escapeBarButton, tabBarButton, shiftBarButton, controlBarButton, altBarButton, deleteBarButton, leftBarButton, downBarButton, upBarButton, rightBarButton, f1BarButton, f2BarButton, f3BarButton, f4BarButton, f5BarButton, f6BarButton, f7BarButton, f8BarButton, f9BarButton, f10BarButton, f11BarButton, f12BarButton, flexibleSpace, nil]]; + // Calculates remaining space for function keys, except for the `Done` button. + [functionToolbarView setFrame:CGRectMake(0, 0, self.bounds.size.width - BUTTON_WIDTH > TOOLBAR_WIDTH ? self.bounds.size.width - BUTTON_WIDTH : TOOLBAR_WIDTH, BUTTON_HEIGHT)]; + + UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, BUTTON_HEIGHT)]; + scrollView.autoresizingMask = UIViewAutoresizingNone; + scrollView.contentSize = functionToolbarView.frame.size; + scrollView.scrollEnabled = self.bounds.size.width - BUTTON_WIDTH > TOOLBAR_WIDTH ? false : true; + scrollView.bounces = false; + scrollView.bouncesZoom = false; + scrollView.showsVerticalScrollIndicator = false; + scrollView.showsHorizontalScrollIndicator = false; + [scrollView setBackgroundColor: [UIColor darkGrayColor]]; + + [scrollView addSubview:functionToolbarView]; + UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithCustomView:scrollView]; + UIToolbar *toolbarView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, BUTTON_HEIGHT)]; + [toolbarView setItems:[NSArray arrayWithObjects:negativeSeperator, doneBarButton, customItem, negativeSeperator, nil]]; + [toolbarView setBackgroundColor: [UIColor darkGrayColor]]; + keyInputField.inputAccessoryView = toolbarView; #endif [keyInputField becomeFirstResponder]; [keyInputField addTarget:self action:@selector(onKeyboardPressed:) forControlEvents:UIControlEventEditingChanged]; @@ -390,7 +434,7 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { } } -- (UIBarButtonItem *)createButtonWithImageNamed:(NSString *)imageName backgroundColor:(UIColor *)backgroundColor target:(id)target action:(SEL)action keyCode:(NSInteger)keyCode isToggleable:(BOOL)isToggleable { +- (UIBarButtonItem *)createButtonWithImageNamed:(NSString *)imageName backgroundColor:(UIColor *)backgroundColor buttonWidth:(CGFloat)buttonWidth target:(id)target action:(SEL)action keyCode:(NSInteger)keyCode isToggleable:(BOOL)isToggleable { UIImage *image = [UIImage imageNamed:imageName]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setImage:image forState:UIControlStateNormal]; @@ -399,6 +443,7 @@ - (UIBarButtonItem *)createButtonWithImageNamed:(NSString *)imageName background button.imageView.backgroundColor = backgroundColor; button.imageView.layer.cornerRadius = 10.0; button.imageEdgeInsets = UIEdgeInsetsMake(6, 6, 6, 6); + [button addConstraint:[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:buttonWidth]]; [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside]; objc_setAssociatedObject(button, "keyCode", @(keyCode), OBJC_ASSOCIATION_RETAIN_NONATOMIC); objc_setAssociatedObject(button, "isToggleable", @(isToggleable), OBJC_ASSOCIATION_RETAIN_NONATOMIC);