Browse files

2010-02-08 Chris Howie <cdhowie@gmail.com>

	* gui.cs: ProcessColdKey is broadcast to all widgets just like
	ProcessHotKey, but after ProcessKey instead of before.

	This method is now used by Button to implement default-button
	logic.  This prevents a default button from consuming '\n' keys when there is
	another default	button, or some other widget interested in '\n' when it it focused
	(like perhaps a TextArea widget).
	

2009-04-24  Miguel de Icaza  <miguel@novell.com>

svn path=/trunk/mono-curses/; revision=151080
  • Loading branch information...
1 parent e3fc834 commit 8450bf90940f726ab8f353376976c8c99c8222b5 @migueldeicaza migueldeicaza committed Feb 9, 2010
Showing with 139 additions and 1 deletion.
  1. +11 −0 ChangeLog
  2. +1 −1 attrib.c
  3. +19 −0 docs/Mono.Terminal/Button.xml
  4. +19 −0 docs/Mono.Terminal/Container.xml
  5. +38 −0 docs/Mono.Terminal/Widget.xml
  6. +51 −0 gui.cs
View
11 ChangeLog
@@ -1,3 +1,14 @@
+2010-02-08 Chris Howie <cdhowie@gmail.com>
+
+ * gui.cs: ProcessColdKey is broadcast to all widgets just like
+ ProcessHotKey, but after ProcessKey instead of before.
+
+ This method is now used by Button to implement default-button
+ logic. This prevents a default button from consuming '\n' keys when there is
+ another default button, or some other widget interested in '\n' when it it focused
+ (like perhaps a TextArea widget).
+
+
2009-04-24 Miguel de Icaza <miguel@novell.com>
* gui.cs (Entry): Raise the Changed event if set.
View
2 attrib.c
@@ -40,7 +40,7 @@ main (int argc, char *argv [])
int diff;
initscr ();
- fprintf (OUT, "/*\n * This file is autogenerated by the attrib.c program, do not edit \n*/\n\n");
+ fprintf (OUT, "/*\n * This file is autogenerated by the attrib.c program, do not edit \n */\n\n");
fprintf (OUT, "using System;\n\n"
"namespace Mono.Terminal {\n"
"public partial class Curses {\n");
View
19 docs/Mono.Terminal/Button.xml
@@ -158,6 +158,25 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
+ <Member MemberName="ProcessColdKey">
+ <MemberSignature Language="C#" Value="public override bool ProcessColdKey (int key);" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Boolean</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="key" Type="System.Int32" />
+ </Parameters>
+ <Docs>
+ <param name="key">To be added.</param>
+ <summary>To be added.</summary>
+ <returns>To be added.</returns>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="ProcessHotKey">
<MemberSignature Language="C#" Value="public override bool ProcessHotKey (int key);" />
<MemberType>Method</MemberType>
View
19 docs/Mono.Terminal/Container.xml
@@ -372,6 +372,25 @@
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
</Member>
+ <Member MemberName="ProcessColdKey">
+ <MemberSignature Language="C#" Value="public override bool ProcessColdKey (int key);" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Boolean</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="key" Type="System.Int32" />
+ </Parameters>
+ <Docs>
+ <param name="key">To be added.</param>
+ <summary>To be added.</summary>
+ <returns>To be added.</returns>
+ <remarks>To be added.</remarks>
+ </Docs>
+ </Member>
<Member MemberName="ProcessHotKey">
<MemberSignature Language="C#" Value="public override bool ProcessHotKey (int key);" />
<MemberType>Method</MemberType>
View
38 docs/Mono.Terminal/Widget.xml
@@ -526,6 +526,44 @@
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
</Member>
+ <Member MemberName="ProcessColdKey">
+ <MemberSignature Language="C#" Value="public virtual bool ProcessColdKey (int key);" />
+ <MemberType>Method</MemberType>
+ <AssemblyInfo>
+ <AssemblyVersion>1.0.0.0</AssemblyVersion>
+ </AssemblyInfo>
+ <ReturnValue>
+ <ReturnType>System.Boolean</ReturnType>
+ </ReturnValue>
+ <Parameters>
+ <Parameter Name="key" Type="System.Int32" />
+ </Parameters>
+ <Docs>
+ <param name="key">To be added.</param>
+ <summary>
+ This method can be overwritten by widgets that
+ want to provide accelerator functionality
+ (Alt-key for example), but without
+ interefering with normal ProcessKey behavior.
+ </summary>
+ <returns>To be added.</returns>
+ <remarks>
+ <para>
+ After keys are sent to the widgets on the
+ current Container, all the widgets are
+ processed and the key is passed to the widgets
+ to allow some of them to process the keystroke
+ as a cold-key. </para>
+ <para>
+ This functionality is used, for example, by
+ default buttons to act on the enter key.
+ Processing this as a hot-key would prevent
+ non-default buttons from consuming the enter
+ keypress when they have the focus.
+ </para>
+ </remarks>
+ </Docs>
+ </Member>
<Member MemberName="ProcessHotKey">
<MemberSignature Language="C#" Value="public virtual bool ProcessHotKey (int key);" />
<MemberType>Method</MemberType>
View
51 gui.cs
@@ -335,6 +335,32 @@ public virtual bool ProcessHotKey (int key)
{
return false;
}
+
+ /// <summary>
+ /// This method can be overwritten by widgets that
+ /// want to provide accelerator functionality
+ /// (Alt-key for example), but without
+ /// interefering with normal ProcessKey behavior.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// After keys are sent to the widgets on the
+ /// current Container, all the widgets are
+ /// processed and the key is passed to the widgets
+ /// to allow some of them to process the keystroke
+ /// as a cold-key. </para>
+ /// <para>
+ /// This functionality is used, for example, by
+ /// default buttons to act on the enter key.
+ /// Processing this as a hot-key would prevent
+ /// non-default buttons from consuming the enter
+ /// keypress when they have the focus.
+ /// </para>
+ /// </remarks>
+ public virtual bool ProcessColdKey (int key)
+ {
+ return false;
+ }
/// <summary>
/// Moves inside the first location inside the container
@@ -1017,11 +1043,17 @@ public override bool ProcessHotKey (int key)
return false;
}
+ return false;
+ }
+
+ public override bool ProcessColdKey (int key)
+ {
if (is_default && key == '\n'){
if (Clicked != null)
Clicked (this, EventArgs.Empty);
return true;
}
+
return false;
}
@@ -1754,6 +1786,22 @@ public override bool ProcessHotKey (int key)
return false;
}
+ public override bool ProcessColdKey (int key)
+ {
+ if (focused != null)
+ if (focused.ProcessColdKey (key))
+ return true;
+
+ foreach (Widget w in widgets){
+ if (w == focused)
+ continue;
+
+ if (w.ProcessColdKey (key))
+ return true;
+ }
+ return false;
+ }
+
public override void ProcessMouse (Curses.MouseEvent ev)
{
int bx, by;
@@ -2691,6 +2739,9 @@ static public void Run (Container container)
if (container.ProcessKey (ch))
continue;
+ if (container.ProcessColdKey (ch))
+ continue;
+
// Control-c, quit the current operation.
if (ch == 3)
break;

0 comments on commit 8450bf9

Please sign in to comment.