~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/embedding/browser/powerplant/source/CUrlField.cp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
Import upstream version 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include "CUrlField.h"
 
3
#include <LString.h>
 
4
#include <PP_KeyCodes.h>
 
5
 
 
6
// CUrlField:
 
7
// A text edit field that broadcasts its PaneID on Return or Enter.
 
8
 
 
9
 
 
10
// ---------------------------------------------------------------------------
 
11
//      � CUrlField                                                             Stream Constructor                [public]
 
12
// ---------------------------------------------------------------------------
 
13
 
 
14
CUrlField::CUrlField(LStream*   inStream)
 
15
        : LEditText(inStream)
 
16
{
 
17
}
 
18
 
 
19
 
 
20
// ---------------------------------------------------------------------------
 
21
//      � ~CUrlField                                                    Destructor                                [public]
 
22
// ---------------------------------------------------------------------------
 
23
 
 
24
CUrlField::~CUrlField()
 
25
{
 
26
}
 
27
 
 
28
 
 
29
// ---------------------------------------------------------------------------
 
30
//      � HandleKeyPress
 
31
// ---------------------------------------------------------------------------
 
32
//      Broadcast the paneID when the user hits Return or Enter
 
33
 
 
34
Boolean
 
35
CUrlField::HandleKeyPress(const EventRecord     &inKeyEvent)
 
36
{
 
37
        Boolean         keyHandled = true;
 
38
        SInt16          theChar = (SInt16) (inKeyEvent.message & charCodeMask);
 
39
 
 
40
        if (theChar == char_Return || theChar == char_Enter)
 
41
        {
 
42
                Str255 urlString;
 
43
                BroadcastMessage(GetPaneID(), (void*)GetDescriptor(urlString));
 
44
        }
 
45
        else
 
46
                keyHandled = Inherited::HandleKeyPress(inKeyEvent);
 
47
 
 
48
        return keyHandled;
 
49
}
 
50
 
 
51
 
 
52
// ---------------------------------------------------------------------------
 
53
//      � ClickSelf
 
54
// ---------------------------------------------------------------------------
 
55
// Select everything when a single click gives us the focus
 
56
 
 
57
void
 
58
CUrlField::ClickSelf(const SMouseDownEvent      &inMouseDown)
 
59
{
 
60
        Boolean wasTarget = IsTarget();
 
61
 
 
62
        Inherited::ClickSelf(inMouseDown);
 
63
 
 
64
        if (!wasTarget)
 
65
        {
 
66
                ControlEditTextSelectionRec     selection;
 
67
                GetSelection(selection);
 
68
                if (selection.selStart == selection.selEnd)
 
69
                        SelectAll();
 
70
        }
 
71
}
 
72