1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00
This commit is contained in:
jules 2008-04-09 09:41:00 +00:00
parent 92790c28eb
commit 5ec41226c6
3 changed files with 55 additions and 46 deletions

View file

@ -1676,16 +1676,23 @@ private:
default:
used = handleKeyUpOrDown();
if ((currentModifiers & (ModifierKeys::ctrlModifier | ModifierKeys::altModifier)) != 0)
{
MSG msg;
if (! PeekMessage (&msg, hwnd, WM_CHAR, WM_DEADCHAR, PM_NOREMOVE))
{
// if there isn't a WM_CHAR or WM_DEADCHAR message pending, we need to
// manually generate the key-press event that matches this key-down.
#if JUCE_ENABLE_WIN98_COMPATIBILITY
const UINT keyChar = wMapVirtualKeyW != 0 ? wMapVirtualKeyW (key, 2)
: MapVirtualKey (key, 2);
const UINT keyChar = wMapVirtualKeyW != 0 ? wMapVirtualKeyW (key, 2)
: MapVirtualKey (key, 2);
#else
const UINT keyChar = MapVirtualKeyW (key, 2);
const UINT keyChar = MapVirtualKeyW (key, 2);
#endif
used = handleKeyPress ((int) LOWORD (keyChar), 0) || used;
used = handleKeyPress ((int) LOWORD (keyChar), 0) || used;
}
}
break;
@ -1699,6 +1706,7 @@ private:
updateKeyModifiers();
juce_wchar textChar = (juce_wchar) key;
const int virtualScanCode = (flags >> 16) & 0xff;
if (key >= '0' && key <= '9')
@ -1723,9 +1731,6 @@ private:
}
else
{
if ((currentModifiers & (ModifierKeys::ctrlModifier | ModifierKeys::altModifier)) != 0)
return false;
// convert the scan code to an unmodified character code..
#if JUCE_ENABLE_WIN98_COMPATIBILITY
const UINT virtualKey = wMapVirtualKeyW != 0 ? wMapVirtualKeyW (virtualScanCode, 1)
@ -1742,7 +1747,13 @@ private:
const DWORD converted = wToUnicode (virtualKey, virtualScanCode, keyState,
unicodeChar, 32, 0);
if (converted > 0)
textChar = unicodeChar[0];
{
// ahem.. can't actually remember why this section of code was originall here,
// so if you see this assertion, please let me know what you were doing at
// the time!
jassert (textChar == unicodeChar[0]);
// textChar = unicodeChar[0];
}
}
#else
const UINT virtualKey = MapVirtualKeyW (virtualScanCode, 1);
@ -1755,7 +1766,13 @@ private:
const DWORD converted = ToUnicode (virtualKey, virtualScanCode, keyState,
unicodeChar, 32, 0);
if (converted > 0)
textChar = unicodeChar[0];
{
// ahem.. can't actually remember why this section of code was originall here,
// so if you see this assertion, please let me know what you were doing at
// the time!
jassert (textChar == unicodeChar[0]);
// textChar = unicodeChar[0];
}
}
#endif
@ -1763,6 +1780,10 @@ private:
if (keyChar != 0)
key = (int) keyChar;
// avoid sending junk text characters for some control-key combinations
if (textChar < ' ' && (currentModifiers & (ModifierKeys::ctrlModifier | ModifierKeys::altModifier)) != 0)
textChar = 0;
}
return handleKeyPress (key, textChar);

View file

@ -1825,40 +1825,32 @@ bool TextEditor::keyPressed (const KeyPress& key)
{
newTransaction();
int newPos;
if (isMultiLine() && key.isKeyCode (KeyPress::upKey))
{
moveCursorTo (indexAtPosition (cursorX, cursorY - 1),
key.getModifiers().isShiftDown());
}
newPos = indexAtPosition (cursorX, cursorY - 1);
else if (moveInWholeWordSteps)
{
moveCursorTo (findWordBreakBefore (getCaretPosition()),
key.getModifiers().isShiftDown());
}
newPos = findWordBreakBefore (getCaretPosition());
else
{
moveCursorTo (getCaretPosition() - 1, key.getModifiers().isShiftDown());
}
newPos = getCaretPosition() - 1;
moveCursorTo (newPos, key.getModifiers().isShiftDown());
}
else if (key.isKeyCode (KeyPress::rightKey)
|| key.isKeyCode (KeyPress::downKey))
{
newTransaction();
if (key.isKeyCode (KeyPress::downKey) && isMultiLine())
{
moveCursorTo (indexAtPosition (cursorX, cursorY + cursorHeight + 1),
key.getModifiers().isShiftDown());
}
int newPos;
if (isMultiLine() && key.isKeyCode (KeyPress::downKey))
newPos = indexAtPosition (cursorX, cursorY + cursorHeight + 1);
else if (moveInWholeWordSteps)
{
moveCursorTo (findWordBreakAfter (getCaretPosition()),
key.getModifiers().isShiftDown());
}
newPos = findWordBreakAfter (getCaretPosition());
else
{
moveCursorTo (getCaretPosition() + 1, key.getModifiers().isShiftDown());
}
newPos = getCaretPosition() + 1;
moveCursorTo (newPos, key.getModifiers().isShiftDown());
}
else if (key.isKeyCode (KeyPress::pageDownKey) && isMultiLine())
{
@ -1957,15 +1949,12 @@ bool TextEditor::keyPressed (const KeyPress& key)
}
else if (key == KeyPress::returnKey)
{
if (! isReadOnly())
{
newTransaction();
newTransaction();
if (returnKeyStartsNewLine)
insertTextAtCursor (T("\n"));
else
returnPressed();
}
if (returnKeyStartsNewLine)
insertTextAtCursor (T("\n"));
else
returnPressed();
}
else if (key.isKeyCode (KeyPress::escapeKey))
{
@ -1973,12 +1962,10 @@ bool TextEditor::keyPressed (const KeyPress& key)
moveCursorTo (getCaretPosition(), false);
escapePressed();
}
else if (key.getTextCharacter() != 0
&& (! isReadOnly())
&& (tabKeyUsed || ! key.isKeyCode (KeyPress::tabKey)))
else if (key.getTextCharacter() >= ' '
|| (tabKeyUsed && (key.getTextCharacter() == '\t')))
{
if (! isReadOnly())
insertTextAtCursor (String::charToString (key.getTextCharacter()));
insertTextAtCursor (String::charToString (key.getTextCharacter()));
lastTransactionTime = Time::getApproximateMillisecondCounter();
}

View file

@ -152,6 +152,7 @@ bool Font::operator!= (const Font& other) const throw()
void Font::setTypefaceName (const String& faceName) throw()
{
typefaceName = faceName;
typeface = 0;
ascent = 0;
}