Fix html submit button value that is included with form data (issue #226)

--HG--
branch : fix-issue-226
hg/feature/cef3
Nimetu 10 years ago
parent 6596af9682
commit 85f63b7db3

@ -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;
};
}

@ -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;

@ -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)

@ -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
}
}
// Add the button coordinates
HTParseFormInput(formfields, (_PostFormSubmitButton + "_x=0").c_str());
HTParseFormInput(formfields, (_PostFormSubmitButton + "_y=0").c_str());
if (_PostFormSubmitType == "image")
{
// Add the button coordinates
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);

@ -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);
}
}
}

Loading…
Cancel
Save