mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-30 04:40:53 +00:00
Fix html submit button value that is included with form data (issue #226)
This commit is contained in:
parent
bdfa7a624e
commit
e2517b8ebc
5 changed files with 55 additions and 8 deletions
|
@ -50,6 +50,8 @@ namespace NLGUI
|
||||||
// see interface.txt for meaning of auto
|
// see interface.txt for meaning of auto
|
||||||
_ToolTipParentPosRef= Hotspot_TTAuto;
|
_ToolTipParentPosRef= Hotspot_TTAuto;
|
||||||
_ToolTipPosRef= Hotspot_TTAuto;
|
_ToolTipPosRef= Hotspot_TTAuto;
|
||||||
|
_EventX = 0;
|
||||||
|
_EventY = 0;
|
||||||
resizer = false;
|
resizer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +72,9 @@ namespace NLGUI
|
||||||
|
|
||||||
bool handleEvent (const NLGUI::CEventDescriptor &event);
|
bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||||
|
|
||||||
|
sint32 getEventX() { return _EventX; }
|
||||||
|
sint32 getEventY() { return _EventY; }
|
||||||
|
|
||||||
virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; }
|
virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; }
|
||||||
|
|
||||||
/// Debug
|
/// Debug
|
||||||
|
@ -181,6 +186,9 @@ namespace NLGUI
|
||||||
static std::map< std::string, std::map< std::string, std::string > > AHCache;
|
static std::map< std::string, std::map< std::string, std::string > > AHCache;
|
||||||
|
|
||||||
bool resizer;
|
bool resizer;
|
||||||
|
|
||||||
|
sint32 _EventX;
|
||||||
|
sint32 _EventY;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ namespace NLGUI
|
||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
// submit form
|
// 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
|
// Browse error
|
||||||
void browseError (const char *msg);
|
void browseError (const char *msg);
|
||||||
|
@ -328,7 +328,11 @@ namespace NLGUI
|
||||||
bool _BrowseNextTime;
|
bool _BrowseNextTime;
|
||||||
bool _PostNextTime;
|
bool _PostNextTime;
|
||||||
uint _PostFormId;
|
uint _PostFormId;
|
||||||
|
std::string _PostFormSubmitType;
|
||||||
std::string _PostFormSubmitButton;
|
std::string _PostFormSubmitButton;
|
||||||
|
std::string _PostFormSubmitValue;
|
||||||
|
sint32 _PostFormSubmitX;
|
||||||
|
sint32 _PostFormSubmitY;
|
||||||
|
|
||||||
// Browsing..
|
// Browsing..
|
||||||
bool _Browsing;
|
bool _Browsing;
|
||||||
|
|
|
@ -701,6 +701,11 @@ namespace NLGUI
|
||||||
//pIM->submitEvent ("button_click:"+getId());
|
//pIM->submitEvent ("button_click:"+getId());
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// top-right corner is EventX=0, EventY=0
|
||||||
|
_EventX = eventDesc.getX() - _XReal;
|
||||||
|
_EventY = (_YReal + _HReal) - eventDesc.getY();
|
||||||
|
|
||||||
runLeftClickAction();
|
runLeftClickAction();
|
||||||
if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example)
|
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];
|
normal = value[MY_HTML_INPUT_SRC];
|
||||||
|
|
||||||
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
|
// 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
|
// Add the ctrl button
|
||||||
addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over,
|
addButton (CCtrlButton::PushButton, name, normal, pushed.empty()?normal:pushed, over,
|
||||||
|
@ -1241,7 +1241,15 @@ namespace NLGUI
|
||||||
text = value[MY_HTML_INPUT_VALUE];
|
text = value[MY_HTML_INPUT_VALUE];
|
||||||
|
|
||||||
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
|
// 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, "|", "|"))
|
||||||
|
;
|
||||||
|
param = param + "|submit_button_value=" + tmp;
|
||||||
|
}
|
||||||
|
|
||||||
// Add the ctrl button
|
// Add the ctrl button
|
||||||
if (!_Paragraph)
|
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 ?
|
// Form id valid ?
|
||||||
if (formId < _Forms.size())
|
if (formId < _Forms.size())
|
||||||
{
|
{
|
||||||
_PostNextTime = true;
|
_PostNextTime = true;
|
||||||
_PostFormId = formId;
|
_PostFormId = formId;
|
||||||
|
_PostFormSubmitType = submitButtonType;
|
||||||
_PostFormSubmitButton = submitButtonName;
|
_PostFormSubmitButton = submitButtonName;
|
||||||
|
_PostFormSubmitValue = submitButtonValue;
|
||||||
|
_PostFormSubmitX = x;
|
||||||
|
_PostFormSubmitY = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3918,9 +3930,22 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the button coordinates
|
if (_PostFormSubmitType == "image")
|
||||||
HTParseFormInput(formfields, (_PostFormSubmitButton + "_x=0").c_str());
|
{
|
||||||
HTParseFormInput(formfields, (_PostFormSubmitButton + "_y=0").c_str());
|
// 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
|
// Add custom params
|
||||||
addHTTPPostParams(formfields, _TrustedDomain);
|
addHTTPPostParams(formfields, _TrustedDomain);
|
||||||
|
|
|
@ -1117,6 +1117,11 @@ class CHandlerHTMLSubmitForm : public IActionHandler
|
||||||
fromString(getParam (sParams, "form"), form);
|
fromString(getParam (sParams, "form"), form);
|
||||||
|
|
||||||
string submit_button = getParam (sParams, "submit_button");
|
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);
|
CInterfaceElement *element = CWidgetManager::getInstance()->getElementFromId(container);
|
||||||
{
|
{
|
||||||
|
@ -1125,7 +1130,7 @@ class CHandlerHTMLSubmitForm : public IActionHandler
|
||||||
if (groupHtml)
|
if (groupHtml)
|
||||||
{
|
{
|
||||||
// Submit the form the url
|
// 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…
Reference in a new issue