Nux

Merge lp:~azzar1/nux/fix-980184-987294 into lp:nux/2.0

Proposed by Andrea Azzarone on 2012-04-25
Status: Merged
Approved by: Andrea Azzarone on 2012-04-25
Approved revision: 615
Merged at revision: 614
Proposed branch: lp:~azzar1/nux/fix-980184-987294
Merge into: lp:nux/2.0
Diff against target: 127 lines (+70/-0)
2 files modified
Nux/TextEntry.cpp (+8/-0)
tests/xtest-text-entry.cpp (+62/-0)
To merge this branch: bzr merge lp:~azzar1/nux/fix-980184-987294
Reviewer Review Type Date Requested Status
Jay Taoko (community) 2012-04-25 Approve on 2012-04-25
Review via email: mp+103505@code.launchpad.net

Commit message

Fixes bugs 987294 and 980184.

Description of the change

== Problem ==
Dash - Arrow keys not working in the search bar on second use.
Dash doesn't ever respond to <enter> when the previous search is recalled

== Test ==
Auto tests added.

To post a comment you must log in.
Jay Taoko (jaytaoko) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/TextEntry.cpp'
2--- Nux/TextEntry.cpp 2012-03-29 04:18:48 +0000
3+++ Nux/TextEntry.cpp 2012-04-25 15:40:36 +0000
4@@ -2327,6 +2327,14 @@
5 key_sym == NUX_VK_TAB ||
6 key_sym == NUX_VK_ESCAPE)
7 {
8+ if (key_sym == NUX_VK_LEFT ||
9+ key_sym == NUX_VK_RIGHT ||
10+ key_sym == NUX_VK_ENTER ||
11+ key_sym == NUX_KP_ENTER)
12+ {
13+ return true;
14+ }
15+
16 if (multiline_ && (key_sym == NUX_VK_UP))
17 {
18 // Navigate between the lines of the text entry.
19
20=== modified file 'tests/xtest-text-entry.cpp'
21--- tests/xtest-text-entry.cpp 2012-03-02 05:34:03 +0000
22+++ tests/xtest-text-entry.cpp 2012-04-25 15:40:36 +0000
23@@ -38,10 +38,15 @@
24 virtual void UserInterfaceSetup();
25
26 void TextEntryClick(nux::TextEntry* text_entry);
27+ void OnActivated();
28+ void OnCursorMoved(int);
29 void ResetEvents();
30+
31 nux::TextEntry* text_entry_;
32
33 bool clicked_;
34+ bool activated_;
35+ bool cursor_moved_;
36 };
37
38 TextTextEntry::TextTextEntry(const char* program_name,
39@@ -49,6 +54,9 @@
40 int window_height,
41 int program_life_span)
42 : ProgramTemplate(program_name, window_width, window_height, program_life_span)
43+ , clicked_(false)
44+ , activated_(false)
45+ , cursor_moved_(false)
46 {
47 ResetEvents();
48 text_entry_ = NULL;
49@@ -62,6 +70,8 @@
50 void TextTextEntry::ResetEvents()
51 {
52 clicked_ = false;
53+ activated_ = false;
54+ cursor_moved_ = false;
55 }
56
57 void TextTextEntry::TextEntryClick(nux::TextEntry* text_entry)
58@@ -72,10 +82,22 @@
59 }
60 }
61
62+void TextTextEntry::OnActivated()
63+{
64+ activated_ = true;
65+}
66+
67+void TextTextEntry::OnCursorMoved(int position)
68+{
69+ cursor_moved_ = true;
70+}
71+
72 void TextTextEntry::UserInterfaceSetup()
73 {
74 nux::VLayout* main_layout = new nux::VLayout(NUX_TRACKER_LOCATION);
75 text_entry_ = new nux::TextEntry("", NUX_TRACKER_LOCATION);
76+ text_entry_->activated.connect(sigc::mem_fun(this, &TextTextEntry::OnActivated));
77+ text_entry_->cursor_moved.connect(sigc::mem_fun(this, &TextTextEntry::OnCursorMoved));
78 text_entry_->SetFontSize(76);
79
80 main_layout->AddView(text_entry_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
81@@ -157,6 +179,46 @@
82
83 // Type "Nux"
84 // The cursor is at the end of the line
85+ // Unset/Set the focus on the text entry
86+ // Move the cursor
87+ {
88+ test.ViewSendString("Nux");
89+ test.TestReportMsg(test_textentry->text_entry_->GetText() == "Nux", "Typed \"Nux\"");
90+
91+ test_textentry->GetWindowThread()->GetWindowCompositor().SetKeyFocusArea(NULL);
92+ test_textentry->GetWindowThread()->GetWindowCompositor().SetKeyFocusArea(test_textentry->text_entry_);
93+
94+ test_textentry->ResetEvents();
95+ test.ViewSendLeft();
96+ nux::SleepForMilliseconds(500);
97+ test.TestReportMsg(test_textentry->cursor_moved_, "Cursor moved.");
98+
99+ test.ViewSendCtrlA();
100+ test.ViewSendDelete();
101+ }
102+
103+ // Type "Nux"
104+ // The cursor is at the end of the line
105+ // Unset/Set the focus on the text entry
106+ // Press enter
107+ {
108+ test.ViewSendString("Nux");
109+ test.TestReportMsg(test_textentry->text_entry_->GetText() == "Nux", "Typed \"Nux\"");
110+
111+ test_textentry->GetWindowThread()->GetWindowCompositor().SetKeyFocusArea(NULL);
112+ test_textentry->GetWindowThread()->GetWindowCompositor().SetKeyFocusArea(test_textentry->text_entry_);
113+
114+ test_textentry->ResetEvents();
115+ test.ViewSendReturn();
116+ nux::SleepForMilliseconds(500);
117+ test.TestReportMsg(test_textentry->activated_, "Activated.");
118+
119+ test.ViewSendCtrlA();
120+ test.ViewSendDelete();
121+ }
122+
123+ // Type "Nux"
124+ // The cursor is at the end of the line
125 // Simulate CTRL+A to select the entire text
126 // Simulate DELETE key to delete the text
127 {

Subscribers

People subscribed via source and target branches

to all changes: