Пример #1
0
void TVideoEditorText::KeyDown(const char *bytes, int32 numBytes)
{
	char theChar = *bytes;
			
	// Increment our counter
	m_KeyCount++;
	if (m_KeyCount > 2)
		m_KeyCount = 1;
		
	//	Check for a return or enter 
	if (theChar == B_ENTER || theChar == B_RETURN || theChar == 'r')
	{
		MakeFocus(false);
	}		
	// We have a number.  Update the cell...
	else if ( isdigit(theChar) )
	{
		UpdateCurrentCell(theChar);	
	}
	// Reset selected cell to zero
	else if ( IsDelete(theChar) || IsBackspace(theChar) )
	{
		//ClearCell();
	}
	// Tab key or period '.' moves us through the time elements
	else if( IsTab(theChar) || theChar == '.' )
	{	
		// Check for shift key.  This move us back through the elements
		if ( IsShiftKeyDown() )		
			DecrementCell();
		else
			IncrementCell();
	}
	else if ( IsArrows(theChar) )
	{
		switch(theChar)
		{
			// Increment value
			case B_UP_ARROW:
				break;
				
			// Decrement value
			case B_DOWN_ARROW:
				break;
				
			// Select next cell
			case B_LEFT_ARROW:
				DecrementCell();
				break;
				
			// Select previous cell
			case B_RIGHT_ARROW:
				IncrementCell();
				break;
		}
	}
	// Illegal character
	else
		;//beep();
}
bool CInputField::CoreHandleKey(wchar_t key)
{
    if (key == KEY_LEFT)
        Move(-1, true);
    else if (key == KEY_RIGHT)
        Move(1, true);
    else if (key == KEY_HOME)
        Move(0, false);
    else if (key == KEY_END)
        Move(m_Text.length(), false);
    else if (IsEnter(key))
        PushEvent(EVENT_CALLBACK);
    else if (key == KEY_DC)
        Delch(m_StartPos + m_CursorPos);
    else if (IsBackspace(key))
    {
        Delch(m_StartPos + m_CursorPos - 1);
        Move(-1, true);
    }
    else
    {
        if (ValidChar(&key))
            Addch(key);
        else
            return false;
    }
    
    return true;
}
Пример #3
0
void TNumberTextView::KeyDown(const char *bytes, int32 numBytes)
{
	char theChar = *bytes;
		
	// Accept numbers, delete and arrows
	if( isdigit(theChar) || IsBackspace(theChar) || IsArrows(theChar) || IsDelete(theChar) )
	{
		BTextView::KeyDown(bytes, numBytes);
	}
	// Illegal character
	else
		beep();
}