This commit is contained in:
kervala 2015-01-10 19:08:55 +01:00
commit 223de1a1a4
7 changed files with 62 additions and 14 deletions

View file

@ -50,6 +50,8 @@ namespace NLGUI
// see interface.txt for meaning of auto
_ToolTipParentPosRef= Hotspot_TTAuto;
_ToolTipPosRef= Hotspot_TTAuto;
_EventX = 0;
_EventY = 0;
resizer = false;
}
@ -70,6 +72,9 @@ namespace NLGUI
bool handleEvent (const NLGUI::CEventDescriptor &event);
sint32 getEventX() { return _EventX; }
sint32 getEventY() { return _EventY; }
virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; }
/// Debug
@ -181,6 +186,9 @@ namespace NLGUI
static std::map< std::string, std::map< std::string, std::string > > AHCache;
bool resizer;
sint32 _EventX;
sint32 _EventY;
};
}

View file

@ -107,7 +107,7 @@ namespace NLGUI
void refresh();
// submit form
void submitForm (uint formId, const char *submitButtonName);
void submitForm (uint formId, const char *submitButtonType, const char *submitButtonName, const char *submitButtonValue, sint32 x, sint32 y);
// Browse error
void browseError (const char *msg);
@ -328,7 +328,11 @@ namespace NLGUI
bool _BrowseNextTime;
bool _PostNextTime;
uint _PostFormId;
std::string _PostFormSubmitType;
std::string _PostFormSubmitButton;
std::string _PostFormSubmitValue;
sint32 _PostFormSubmitX;
sint32 _PostFormSubmitY;
// Browsing..
bool _Browsing;

View file

@ -701,6 +701,11 @@ namespace NLGUI
//pIM->submitEvent ("button_click:"+getId());
}
*/
// top-right corner is EventX=0, EventY=0
_EventX = eventDesc.getX() - _XReal;
_EventY = (_YReal + _HReal) - eventDesc.getY();
runLeftClickAction();
if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example)

View file

@ -999,7 +999,8 @@ namespace NLGUI
break;
// OTHER
default:
if ((rEDK.getChar() == KeyRETURN) && !_WantReturn)
bool isKeyRETURN = !rEDK.getKeyCtrl() && rEDK.getChar() == KeyRETURN;
if (isKeyRETURN && !_WantReturn)
{
// update historic.
if(_MaxHistoric)
@ -1030,9 +1031,9 @@ namespace NLGUI
// If the char is not alphanumeric -> return.
// if(!isalnum(ec.Char))
// return
if( (rEDK.getChar()>=32) || (rEDK.getChar() == KeyRETURN) )
if( (rEDK.getChar()>=32) || isKeyRETURN )
{
if (rEDK.getChar() == KeyRETURN)
if (isKeyRETURN)
{
ucstring copyStr= _InputString;
if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn)
@ -1049,7 +1050,7 @@ namespace NLGUI
cutSelection();
}
ucchar c = (rEDK.getChar() == KeyRETURN)?'\n':rEDK.getChar();
ucchar c = isKeyRETURN ? '\n' : rEDK.getChar();
if (isFiltered(c)) return;
switch(_EntryType)
{
@ -1128,7 +1129,7 @@ namespace NLGUI
++ _CursorPos;
triggerOnChangeAH();
}
if (rEDK.getChar() == KeyRETURN)
if (isKeyRETURN)
{
CAHManager::getInstance()->runActionHandler(_AHOnEnter, this, _AHOnEnterParams);
}

View file

@ -1217,7 +1217,7 @@ namespace NLGUI
normal = value[MY_HTML_INPUT_SRC];
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name;
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=image";
// Add the ctrl button
addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over,
@ -1241,7 +1241,15 @@ namespace NLGUI
text = value[MY_HTML_INPUT_VALUE];
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name;
string param = "name=" + getId() + "|form=" + toString (_Forms.size()-1) + "|submit_button=" + name + "|submit_button_type=submit";
if (text.size() > 0)
{
// escape AH param separator
string tmp = text;
while(NLMISC::strFindReplace(tmp, "|", "&#124;"))
;
param = param + "|submit_button_value=" + tmp;
}
// Add the ctrl button
if (!_Paragraph)
@ -3638,14 +3646,18 @@ namespace NLGUI
// ***************************************************************************
void CGroupHTML::submitForm (uint formId, const char *submitButtonName)
void CGroupHTML::submitForm (uint formId, const char *submitButtonType, const char *submitButtonName, const char *submitButtonValue, sint32 x, sint32 y)
{
// Form id valid ?
if (formId < _Forms.size())
{
_PostNextTime = true;
_PostFormId = formId;
_PostFormSubmitType = submitButtonType;
_PostFormSubmitButton = submitButtonName;
_PostFormSubmitValue = submitButtonValue;
_PostFormSubmitX = x;
_PostFormSubmitY = y;
}
}
@ -3918,9 +3930,22 @@ namespace NLGUI
}
}
if (_PostFormSubmitType == "image")
{
// Add the button coordinates
HTParseFormInput(formfields, (_PostFormSubmitButton + "_x=0").c_str());
HTParseFormInput(formfields, (_PostFormSubmitButton + "_y=0").c_str());
if (_PostFormSubmitButton.find_first_of("[") == string::npos)
{
HTParseFormInput(formfields, (_PostFormSubmitButton + "_x=" + NLMISC::toString(_PostFormSubmitX)).c_str());
HTParseFormInput(formfields, (_PostFormSubmitButton + "_y=" + NLMISC::toString(_PostFormSubmitY)).c_str());
}
else
{
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + NLMISC::toString(_PostFormSubmitX)).c_str());
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + NLMISC::toString(_PostFormSubmitY)).c_str());
}
}
else
HTParseFormInput(formfields, (_PostFormSubmitButton + "=" + _PostFormSubmitValue).c_str());
// Add custom params
addHTTPPostParams(formfields, _TrustedDomain);

View file

@ -2207,7 +2207,7 @@ namespace NLGUI
}
// Manage complex "Enter"
if (eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyRETURN)
if( eventDesc.getKeyEventType() == CEventDescriptorKey::keychar && eventDesc.getChar() == NLMISC::KeyRETURN && !eventDesc.getKeyCtrl() )
{
// If the top window has Enter AH
CInterfaceGroup *tw= getTopWindow();

View file

@ -1117,6 +1117,11 @@ class CHandlerHTMLSubmitForm : public IActionHandler
fromString(getParam (sParams, "form"), form);
string submit_button = getParam (sParams, "submit_button");
string type = getParam (sParams, "submit_button_type");
string value = getParam (sParams, "submit_button_value");
sint32 x = pCaller->getEventX();
sint32 y = pCaller->getEventY();
CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId(container);
{
@ -1125,7 +1130,7 @@ class CHandlerHTMLSubmitForm : public IActionHandler
if (groupHtml)
{
// Submit the form the url
groupHtml->submitForm (form, submit_button.c_str ());
groupHtml->submitForm (form, type.c_str(), submit_button.c_str(), value.c_str(), x, y);
}
}
}