Quantcast

Dismiss keyboard @ MonoTouch.Dialog

classic Classic list List threaded Threaded
6 messages Options
Iki
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Dismiss keyboard @ MonoTouch.Dialog

Iki
Hi guys,

I know that this is probably asked million of times but I can find a nice solution to dismiss a keyboard in MonoTouch.Dialog.

On the internet I have found two solutions, one from Miguel,

//Gesture recognizer for handling EndEditing of Elements
    var tap = new UITapGestureRecognizer ();
    tap.AddTarget (() =>{ this.View.EndEditing(true); });

    this.View.AddGestureRecognizer (tap);
//-------------------------------------------------------


and another solution from stack overflow 

//Hide when dragging start
this.TableView.DraggingStarted += (object senderEventArgs e) => 
{
   this.View.EndEditing (true);
};

The problem with these two is that it will block any action that comes from tapping other elements
(example. StringElement) so I can't find a way if using these two to display picker element, or UIAlertView.

Do you have any ideas?

Thanks for help!

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dismiss keyboard @ MonoTouch.Dialog

Nic Wise
I think you need to work out how you want to dismiss it, then trigger
off that. View.EndEditing(true) gets rid of the keyboard, but how you
trigger it is up to you.

The tap gesture isn't too bad, but as you said, it takes over all taps.

I quite like the scroll one - maybe you could also trigger it off the
scroll event/message on the TableView?

Putting a toolbar or view on the keyboard can work, too - PlainText
does it quite well:
https://itunes.apple.com/en/app/plaintext-dropbox-text-editing/id391254385?mt=8

I've never found a solution I liked enough to keep it in, except the
toolbar one, and even then it was clunkey.



On 7 March 2013 08:51, Iki <[hidden email]> wrote:

> Hi guys,
>
> I know that this is probably asked million of times but I can find a nice
> solution to dismiss a keyboard in MonoTouch.Dialog.
>
> On the internet I have found two solutions, one from Miguel,
>
> //Gesture recognizer for handling EndEditing of Elements
>     var tap = new UITapGestureRecognizer ();
>     tap.AddTarget (() =>{ this.View.EndEditing(true); });
>
>     this.View.AddGestureRecognizer (tap);
> //-------------------------------------------------------
>
>
> and another solution from stack overflow
>
> //Hide when dragging start
> this.TableView.DraggingStarted += (object sender, EventArgs e) =>
> {
>    this.View.EndEditing (true);
> };
>
> The problem with these two is that it will block any action that comes from
> tapping other elements
> (example. StringElement) so I can't find a way if using these two to display
> picker element, or UIAlertView.
>
> Do you have any ideas?
>
> Thanks for help!
>
> _______________________________________________
> MonoTouch mailing list
> [hidden email]
> http://lists.ximian.com/mailman/listinfo/monotouch
>



--
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Iki
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dismiss keyboard @ MonoTouch.Dialog

Iki
Hi Nic,

sorry for delay, i really don't like the solution with toolbar above, but the one that you send link to is really nice!

For now I started using this:

stringElement.ReturnKeyType = UIReturnKeyType.Done;
stringElement.ShouldReturn += () => 
{
   stringElement.ResignFirstResponder(true);
   return true;
};

How would one start with adding custom toolbar for MonoTouch.Dialog? 
When using normal UI text field, I have created transparent UIView, and add it as a input accessory view to the UITextField.

I was thinking of adding a subview to the keyboard but I don't know the proper way of referencing keyboard.
I can do it in Objective-C but can't do it using MonoTouch.



I also never found anything that I would like to keep. My latest try was to load a transparent view above the keyboard
On Mar 7, 2013, at 11:18 AM, Nic Wise <[hidden email]> wrote:

I think you need to work out how you want to dismiss it, then trigger
off that. View.EndEditing(true) gets rid of the keyboard, but how you
trigger it is up to you.

The tap gesture isn't too bad, but as you said, it takes over all taps.

I quite like the scroll one - maybe you could also trigger it off the
scroll event/message on the TableView?

Putting a toolbar or view on the keyboard can work, too - PlainText
does it quite well:
https://itunes.apple.com/en/app/plaintext-dropbox-text-editing/id391254385?mt=8

I've never found a solution I liked enough to keep it in, except the
toolbar one, and even then it was clunkey.



On 7 March 2013 08:51, Iki <[hidden email]> wrote:
Hi guys,

I know that this is probably asked million of times but I can find a nice
solution to dismiss a keyboard in MonoTouch.Dialog.

On the internet I have found two solutions, one from Miguel,

//Gesture recognizer for handling EndEditing of Elements
   var tap = new UITapGestureRecognizer ();
   tap.AddTarget (() =>{ this.View.EndEditing(true); });

   this.View.AddGestureRecognizer (tap);
//-------------------------------------------------------


and another solution from stack overflow

//Hide when dragging start
this.TableView.DraggingStarted += (object sender, EventArgs e) =>
{
  this.View.EndEditing (true);
};

The problem with these two is that it will block any action that comes from
tapping other elements
(example. StringElement) so I can't find a way if using these two to display
picker element, or UIAlertView.

Do you have any ideas?

Thanks for help!

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch




--
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dismiss keyboard @ MonoTouch.Dialog

Nic Wise
yeah, you add the custom toolbar by using the InputAccessory - you'd
need to make your own stringelement (copy the one thats there) and add
it in when it's created.

If you have ObjC to code change the keyboard, doing it in MonoTouch
would be the same - you just need to translate it, which is usually
mostly just finding where the names have changed :)

On 7 March 2013 14:28, Iki <[hidden email]> wrote:

> Hi Nic,
>
> sorry for delay, i really don't like the solution with toolbar above, but
> the one that you send link to is really nice!
>
> For now I started using this:
>
> stringElement.ReturnKeyType = UIReturnKeyType.Done;
> stringElement.ShouldReturn += () =>
> {
>    stringElement.ResignFirstResponder(true);
>    return true;
> };
>
> How would one start with adding custom toolbar for MonoTouch.Dialog?
> When using normal UI text field, I have created transparent UIView, and add
> it as a input accessory view to the UITextField.
>
> I was thinking of adding a subview to the keyboard but I don't know the
> proper way of referencing keyboard.
> I can do it in Objective-C but can't do it using MonoTouch.
>
>
>
> I also never found anything that I would like to keep. My latest try was to
> load a transparent view above the keyboard
> On Mar 7, 2013, at 11:18 AM, Nic Wise <[hidden email]> wrote:
>
> I think you need to work out how you want to dismiss it, then trigger
> off that. View.EndEditing(true) gets rid of the keyboard, but how you
> trigger it is up to you.
>
> The tap gesture isn't too bad, but as you said, it takes over all taps.
>
> I quite like the scroll one - maybe you could also trigger it off the
> scroll event/message on the TableView?
>
> Putting a toolbar or view on the keyboard can work, too - PlainText
> does it quite well:
> https://itunes.apple.com/en/app/plaintext-dropbox-text-editing/id391254385?mt=8
>
> I've never found a solution I liked enough to keep it in, except the
> toolbar one, and even then it was clunkey.
>
>
>
> On 7 March 2013 08:51, Iki <[hidden email]> wrote:
>
> Hi guys,
>
> I know that this is probably asked million of times but I can find a nice
> solution to dismiss a keyboard in MonoTouch.Dialog.
>
> On the internet I have found two solutions, one from Miguel,
>
> //Gesture recognizer for handling EndEditing of Elements
>    var tap = new UITapGestureRecognizer ();
>    tap.AddTarget (() =>{ this.View.EndEditing(true); });
>
>    this.View.AddGestureRecognizer (tap);
> //-------------------------------------------------------
>
>
> and another solution from stack overflow
>
> //Hide when dragging start
> this.TableView.DraggingStarted += (object sender, EventArgs e) =>
> {
>   this.View.EndEditing (true);
> };
>
> The problem with these two is that it will block any action that comes from
> tapping other elements
> (example. StringElement) so I can't find a way if using these two to display
> picker element, or UIAlertView.
>
> Do you have any ideas?
>
> Thanks for help!
>
> _______________________________________________
> MonoTouch mailing list
> [hidden email]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
>
>
> --
> Nic Wise
> t.  +44 7788 592 806 | @fastchicken
> b. http://www.fastchicken.co.nz/
>
>



--
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Iki
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dismiss keyboard @ MonoTouch.Dialog

Iki

On Mar 8, 2013, at 12:29 AM, Iki <[hidden email]> wrote:

Hm strange, this is what WriteLine reports

on keyboard loading
<UILayoutContainerView: 0x102557c0; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x10255860>>

on keyboard dismissing
<UILayoutContainerView: 0x102557c0; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x10255860>>
<UIPeripheralHostView: 0x15024b40; frame = (0 264; 320 216); autoresizesSubviews = NO; layer = <UIPeripheralHostLayer: 0xc803d00>>

I managed to get things working, i still need to add animation and tweak up few things, but this looks like pretty elegant solution :))

I will check your solution Nic tomorrow!

Here it is:

//For notification
NSObject observer1observer2;

//Observing Keyboard notifications-------------------------------------------
float keyboardHeight;
UIView dismissalView = null;

//WillShow
observer1 = NSNotificationCenter
.DefaultCenter
.AddObserver
(
UIKeyboard.WillShowNotification
,delegate(NSNotification notification) 
{
RectangleF frame;
if(notification != null)
{
RectangleF kbdRect = UIKeyboard.FrameEndFromNotification(notification);
//double animationDuration = UIKeyboard.AnimationDurationFromNotification(notification);
if(notification.Name == UIKeyboard.WillShowNotification || notification.Name == UIKeyboard.DidShowNotification)
{
//UIView firstResponder = UIApplication.SharedApplication.KeyWindow;

foreach (UIWindow keyboardWindow in UIApplication.SharedApplication.Windows) 
{
foreach(UIView keyboard in keyboardWindow.Subviews)
{
dismissalView = new UIView();
dismissalView.Frame = new RectangleF(0, 0, keyboard.Frame.Size.Width, keyboard.Frame.Size.Height - kbdRect.Height);
dismissalView.BackgroundColor = UIColor.Red;
dismissalView.Alpha = 0.5f;

//Gesture recognizer for handling EndEditing of Elements
var tap = new UITapGestureRecognizer ();
tap.AddTarget (() =>{ this.TableView.EndEditing(true); });
dismissalView.AddGestureRecognizer (tap);

keyboard.AddSubview(dismissalView);
System.Console.WriteLine(keyboard.Description);
}
}

}
);

//WillHide
observer2 = NSNotificationCenter
.DefaultCenter
.AddObserver
(
UIKeyboard.WillHideNotification
,delegate(NSNotification notification) 
{
RectangleF frame;
if(notification != null)
{
RectangleF kbdRect = UIKeyboard.FrameEndFromNotification(notification);
//double animationDuration = UIKeyboard.AnimationDurationFromNotification(notification);
if(notification.Name == UIKeyboard.WillHideNotification)
{
foreach (UIWindow keyboardWindow in UIApplication.SharedApplication.Windows) 
{
foreach(UIView keyboard in keyboardWindow.Subviews)
{
if(dismissalView != null)
{
dismissalView.RemoveFromSuperview();
dismissalView = null;

}

System.Console.WriteLine(keyboard.Description);
}
}
}
);

Not sure about this but it can probably go in ViewDidUnload or in didRecieveMemoryWarning
//Unsubscribing from observers------------------------------
NSNotificationCenter.DefaultCenter.RemoveObserver(observer1);
NSNotificationCenter.DefaultCenter.RemoveObserver(observer1);
//----------------------------------------------------------


On Mar 7, 2013, at 5:04 PM, Nic Wise <[hidden email]> wrote:

This might help:

https://github.com/nicwise/BTProgressHUD/blob/master/BTProgressHUD/BTProgressHUD.cs#L436

But, what happens if you dump out the keyboard.Description in that
loop (just Console.WriteLine it) - maybe it starts with something
else?

On 7 March 2013 15:36, Iki <[hidden email]> wrote:
Great! But regarding ObjC code, this is what i use in mono touch but for
some reason i can't get reference to keyboard

observer1 = NSNotificationCenter
               .DefaultCenter
                   .AddObserver
                   (
                       UIKeyboard.WillShowNotification
                       ,delegate(NSNotification notification)
                       {
                       RectangleF frame;
                       if(notification != null)
                       {
                           RectangleF kbdRect =
UIKeyboard.FrameEndFromNotification(notification);


                           if(notification.Name ==
UIKeyboard.WillShowNotification || notification.Name ==
UIKeyboard.DidShowNotification)
                           {

                               UIView firstResponder =
UIApplication.SharedApplication.KeyWindow;

                               foreach (UIWindow keyboardWindow in
UIApplication.SharedApplication.Windows)
                               {
                                   foreach(UIView keyboard in
keyboardWindow.Subviews)
                                   {

if(keyboard.Description.StartsWith("<UIKeyboard") == true)
                                          {
                                               UIView view = new UIView();
                                            view.Frame = new RectangleF(0,
0, keyboard.Frame.Size.Width, keyboard.Frame.Size.Height);


                                               view.BackgroundColor =
UIColor.Red;

                                               keyboard.AddSubview(view);
                                           }
                                   }
                               }

                           }

                       }

                   }
                );

This compiles nicely but for some reason the last if never happens. If I
just add transparent view when keyboard is displayed, and for some reason
table view bellow scrolls up or down, view will move along with table view.
So for that reason I would want it to be subview of keyboard.

I will try couple more thing regarding that. And also i need to test this
from Xcode, maybe something changed, i didn't use this for some time now.

Thanks anyway Nic!


On Mar 7, 2013, at 3:55 PM, Nic Wise <[hidden email]> wrote:

yeah, you add the custom toolbar by using the InputAccessory - you'd
need to make your own stringelement (copy the one thats there) and add
it in when it's created.

If you have ObjC to code change the keyboard, doing it in MonoTouch
would be the same - you just need to translate it, which is usually
mostly just finding where the names have changed :)

On 7 March 2013 14:28, Iki <[hidden email]> wrote:

Hi Nic,

sorry for delay, i really don't like the solution with toolbar above, but
the one that you send link to is really nice!

For now I started using this:

stringElement.ReturnKeyType = UIReturnKeyType.Done;
stringElement.ShouldReturn += () =>
{
 stringElement.ResignFirstResponder(true);
 return true;
};

How would one start with adding custom toolbar for MonoTouch.Dialog?
When using normal UI text field, I have created transparent UIView, and add
it as a input accessory view to the UITextField.

I was thinking of adding a subview to the keyboard but I don't know the
proper way of referencing keyboard.
I can do it in Objective-C but can't do it using MonoTouch.



I also never found anything that I would like to keep. My latest try was to
load a transparent view above the keyboard
On Mar 7, 2013, at 11:18 AM, Nic Wise <[hidden email]> wrote:

I think you need to work out how you want to dismiss it, then trigger
off that. View.EndEditing(true) gets rid of the keyboard, but how you
trigger it is up to you.

The tap gesture isn't too bad, but as you said, it takes over all taps.

I quite like the scroll one - maybe you could also trigger it off the
scroll event/message on the TableView?

Putting a toolbar or view on the keyboard can work, too - PlainText
does it quite well:
https://itunes.apple.com/en/app/plaintext-dropbox-text-editing/id391254385?mt=8

I've never found a solution I liked enough to keep it in, except the
toolbar one, and even then it was clunkey.



On 7 March 2013 08:51, Iki <[hidden email]> wrote:

Hi guys,

I know that this is probably asked million of times but I can find a nice
solution to dismiss a keyboard in MonoTouch.Dialog.

On the internet I have found two solutions, one from Miguel,

//Gesture recognizer for handling EndEditing of Elements
 var tap = new UITapGestureRecognizer ();
 tap.AddTarget (() =>{ this.View.EndEditing(true); });

 this.View.AddGestureRecognizer (tap);
//-------------------------------------------------------


and another solution from stack overflow

//Hide when dragging start
this.TableView.DraggingStarted += (object sender, EventArgs e) =>
{
this.View.EndEditing (true);
};

The problem with these two is that it will block any action that comes from
tapping other elements
(example. StringElement) so I can't find a way if using these two to display
picker element, or UIAlertView.

Do you have any ideas?

Thanks for help!

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch




--
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/





--
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/





--
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/



_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Iki
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dismiss keyboard @ MonoTouch.Dialog

Iki
In reply to this post by Nic Wise
Hi Nic,

I have reviewed your sample, but for some reason, the only way I can get a reference for the UIKeyboard is with these two keywords:

WHEN LOADING KEYBOARD:
<UILayoutContainerView: 0x102557c0; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x10255860>>

WHEN UNLOADING KEYBOARD:
<UIPeripheralHostView: 0x15024b40; frame = (0 264; 320 216); autoresizesSubviews = NO; layer = <UIPeripheralHostLayer: 0xc803d00>>



On Mar 8, 2013, at 12:29 AM, Iki <[hidden email]> wrote:

Hm strange, this is what WriteLine reports

on keyboard loading
<UILayoutContainerView: 0x102557c0; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x10255860>>

on keyboard dismissing
<UILayoutContainerView: 0x102557c0; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x10255860>>
<UIPeripheralHostView: 0x15024b40; frame = (0 264; 320 216); autoresizesSubviews = NO; layer = <UIPeripheralHostLayer: 0xc803d00>>

I managed to get things working, i still need to add animation and tweak up few things, but this looks like pretty elegant solution :))

I will check your solution Nic tomorrow!

Here it is:

//For notification
NSObject observer1observer2;

//Observing Keyboard notifications-------------------------------------------
float keyboardHeight;
UIView dismissalView = null;

//WillShow
observer1 = NSNotificationCenter
.DefaultCenter
.AddObserver
(
UIKeyboard.WillShowNotification
,delegate(NSNotification notification) 
{
RectangleF frame;
if(notification != null)
{
RectangleF kbdRect = UIKeyboard.FrameEndFromNotification(notification);
//double animationDuration = UIKeyboard.AnimationDurationFromNotification(notification);
if(notification.Name == UIKeyboard.WillShowNotification || notification.Name == UIKeyboard.DidShowNotification)
{
//UIView firstResponder = UIApplication.SharedApplication.KeyWindow;

foreach (UIWindow keyboardWindow in UIApplication.SharedApplication.Windows) 
{
foreach(UIView keyboard in keyboardWindow.Subviews)
{
dismissalView = new UIView();
dismissalView.Frame = new RectangleF(0, 0, keyboard.Frame.Size.Width, keyboard.Frame.Size.Height - kbdRect.Height);
dismissalView.BackgroundColor = UIColor.Red;
dismissalView.Alpha = 0.5f;

//Gesture recognizer for handling EndEditing of Elements
var tap = new UITapGestureRecognizer ();
tap.AddTarget (() =>{ this.TableView.EndEditing(true); });
dismissalView.AddGestureRecognizer (tap);

keyboard.AddSubview(dismissalView);
System.Console.WriteLine(keyboard.Description);
}
}

}
);

//WillHide
observer2 = NSNotificationCenter
.DefaultCenter
.AddObserver
(
UIKeyboard.WillHideNotification
,delegate(NSNotification notification) 
{
RectangleF frame;
if(notification != null)
{
RectangleF kbdRect = UIKeyboard.FrameEndFromNotification(notification);
//double animationDuration = UIKeyboard.AnimationDurationFromNotification(notification);
if(notification.Name == UIKeyboard.WillHideNotification)
{
foreach (UIWindow keyboardWindow in UIApplication.SharedApplication.Windows) 
{
foreach(UIView keyboard in keyboardWindow.Subviews)
{
if(dismissalView != null)
{
dismissalView.RemoveFromSuperview();
dismissalView = null;

}

System.Console.WriteLine(keyboard.Description);
}
}
}
);

Not sure about this but it can probably go in ViewDidUnload or in didRecieveMemoryWarning
//Unsubscribing from observers------------------------------
NSNotificationCenter.DefaultCenter.RemoveObserver(observer1);
NSNotificationCenter.DefaultCenter.RemoveObserver(observer1);
//----------------------------------------------------------


On Mar 7, 2013, at 5:04 PM, Nic Wise <[hidden email]> wrote:

This might help:

https://github.com/nicwise/BTProgressHUD/blob/master/BTProgressHUD/BTProgressHUD.cs#L436

But, what happens if you dump out the keyboard.Description in that
loop (just Console.WriteLine it) - maybe it starts with something
else?

On 7 March 2013 15:36, Iki <[hidden email]> wrote:
Great! But regarding ObjC code, this is what i use in mono touch but for
some reason i can't get reference to keyboard

observer1 = NSNotificationCenter
               .DefaultCenter
                   .AddObserver
                   (
                       UIKeyboard.WillShowNotification
                       ,delegate(NSNotification notification)
                       {
                       RectangleF frame;
                       if(notification != null)
                       {
                           RectangleF kbdRect =
UIKeyboard.FrameEndFromNotification(notification);


                           if(notification.Name ==
UIKeyboard.WillShowNotification || notification.Name ==
UIKeyboard.DidShowNotification)
                           {

                               UIView firstResponder =
UIApplication.SharedApplication.KeyWindow;

                               foreach (UIWindow keyboardWindow in
UIApplication.SharedApplication.Windows)
                               {
                                   foreach(UIView keyboard in
keyboardWindow.Subviews)
                                   {

if(keyboard.Description.StartsWith("<UIKeyboard") == true)
                                          {
                                               UIView view = new UIView();
                                            view.Frame = new RectangleF(0,
0, keyboard.Frame.Size.Width, keyboard.Frame.Size.Height);


                                               view.BackgroundColor =
UIColor.Red;

                                               keyboard.AddSubview(view);
                                           }
                                   }
                               }

                           }

                       }

                   }
                );

This compiles nicely but for some reason the last if never happens. If I
just add transparent view when keyboard is displayed, and for some reason
table view bellow scrolls up or down, view will move along with table view.
So for that reason I would want it to be subview of keyboard.

I will try couple more thing regarding that. And also i need to test this
from Xcode, maybe something changed, i didn't use this for some time now.

Thanks anyway Nic!


On Mar 7, 2013, at 3:55 PM, Nic Wise <[hidden email]> wrote:

yeah, you add the custom toolbar by using the InputAccessory - you'd
need to make your own stringelement (copy the one thats there) and add
it in when it's created.

If you have ObjC to code change the keyboard, doing it in MonoTouch
would be the same - you just need to translate it, which is usually
mostly just finding where the names have changed :)

On 7 March 2013 14:28, Iki <[hidden email]> wrote:

Hi Nic,

sorry for delay, i really don't like the solution with toolbar above, but
the one that you send link to is really nice!

For now I started using this:

stringElement.ReturnKeyType = UIReturnKeyType.Done;
stringElement.ShouldReturn += () =>
{
 stringElement.ResignFirstResponder(true);
 return true;
};

How would one start with adding custom toolbar for MonoTouch.Dialog?
When using normal UI text field, I have created transparent UIView, and add
it as a input accessory view to the UITextField.

I was thinking of adding a subview to the keyboard but I don't know the
proper way of referencing keyboard.
I can do it in Objective-C but can't do it using MonoTouch.



I also never found anything that I would like to keep. My latest try was to
load a transparent view above the keyboard
On Mar 7, 2013, at 11:18 AM, Nic Wise <[hidden email]> wrote:

I think you need to work out how you want to dismiss it, then trigger
off that. View.EndEditing(true) gets rid of the keyboard, but how you
trigger it is up to you.

The tap gesture isn't too bad, but as you said, it takes over all taps.

I quite like the scroll one - maybe you could also trigger it off the
scroll event/message on the TableView?

Putting a toolbar or view on the keyboard can work, too - PlainText
does it quite well:
https://itunes.apple.com/en/app/plaintext-dropbox-text-editing/id391254385?mt=8

I've never found a solution I liked enough to keep it in, except the
toolbar one, and even then it was clunkey.



On 7 March 2013 08:51, Iki <[hidden email]> wrote:

Hi guys,

I know that this is probably asked million of times but I can find a nice
solution to dismiss a keyboard in MonoTouch.Dialog.

On the internet I have found two solutions, one from Miguel,

//Gesture recognizer for handling EndEditing of Elements
 var tap = new UITapGestureRecognizer ();
 tap.AddTarget (() =>{ this.View.EndEditing(true); });

 this.View.AddGestureRecognizer (tap);
//-------------------------------------------------------


and another solution from stack overflow

//Hide when dragging start
this.TableView.DraggingStarted += (object sender, EventArgs e) =>
{
this.View.EndEditing (true);
};

The problem with these two is that it will block any action that comes from
tapping other elements
(example. StringElement) so I can't find a way if using these two to display
picker element, or UIAlertView.

Do you have any ideas?

Thanks for help!

_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch




--
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/





--
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/





--
Nic Wise
t.  +44 7788 592 806 | @fastchicken
b. http://www.fastchicken.co.nz/



_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Loading...