Permalink
Browse files

Added temporary disable function (~) and fix for web view text box is…

…sues
  • Loading branch information...
domesticcatsoftware committed Jan 19, 2012
1 parent 73b6c21 commit 3ef2c10710f007b6d699c2a0b996ce1e3a79bde0
Showing with 22 additions and 4 deletions.
  1. +20 −3 DCIntrospect/DCIntrospect.m
  2. +2 −1 DCIntrospect/DCIntrospectSettings.h
@@ -222,6 +222,14 @@ - (void)start
afterDelay:0.1];
}];
+ // dirty hack for UIWebView keyboard problems
+ [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillShowNotification
+ object:nil
+ queue:nil
+ usingBlock:^(NSNotification *notification) {
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(takeFirstResponder) object:nil];
+ }];
+
// listen for device orientation changes to adjust the status bar
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateViews) name:UIDeviceOrientationDidChangeNotification object:nil];
@@ -259,9 +267,9 @@ - (void)setInvokeGestureRecognizer:(UIGestureRecognizer *)newGestureRecognizer
[mainWindow addGestureRecognizer:invokeGestureRecognizer];
}
-- (void)setKeyboardBindingsOn:(BOOL)newKeyboardBindingsOn
+- (void)setKeyboardBindingsOn:(BOOL)areKeyboardBindingsOn
{
- keyboardBindingsOn = newKeyboardBindingsOn;
+ keyboardBindingsOn = areKeyboardBindingsOn;
if (self.keyboardBindingsOn)
[self.inputTextView becomeFirstResponder];
else
@@ -413,6 +421,15 @@ - (void)textViewDidChangeSelection:(UITextView *)textView
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)string
{
+ if ([string isEqualToString:kDCIntrospectKeysDisableForPeriod])
+ {
+ [self setKeyboardBindingsOn:NO];
+ [[self inputTextView] resignFirstResponder];
+ NSLog(@"DCIntrospect: Disabled for %.1f seconds", kDCIntrospectTemporaryDisableDuration);
+ [self performSelector:@selector(setKeyboardBindingsOn:) withObject:[NSNumber numberWithFloat:YES] afterDelay:kDCIntrospectTemporaryDisableDuration];
+ return NO;
+ }
+
if ([string isEqualToString:kDCIntrospectKeysInvoke])
{
[self invokeIntrospector];
@@ -428,7 +445,7 @@ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range r
return NO;
}
- if ([string isEqualToString:kDCIntrospectKeysToggleViewOutlines])
+ if ([string isEqualToString:kDCIntrospectKeysToggleViewOutlines])
{
[self toggleOutlines];
return NO;
@@ -5,6 +5,7 @@
#define kDCIntrospectFlashOnRedrawColor [UIColor colorWithRed:1.0f green:0.0f blue:0.0f alpha:0.4f] // UIColor
#define kDCIntrospectFlashOnRedrawFlashLength 0.03f // NSTimeInterval
#define kDCIntrospectOpaqueColor [UIColor redColor] // UIColor
+#define kDCIntrospectTemporaryDisableDuration 10. // Seconds
//////////////////
// Key Bindings //
@@ -52,4 +53,4 @@
#define kDCIntrospectKeysMoveToPrevSiblingView @"g"
#define kDCIntrospectKeysEnterGDB @"`" // enters GDB
-
+#define kDCIntrospectKeysDisableForPeriod @"~" // disables DCIntrospect for a given period (see kDCIntrospectTemporaryDisableDuration)

0 comments on commit 3ef2c10

Please sign in to comment.