I'm opening the file dialog by calling
- Code: Select all
browser->GetHost()->RunFileDialog(FILE_DIALOG_OPEN_FOLDER, ...)
The button to accept the selected folder shows the label "Hochladen" (that's german for "upload").
How can I change this label?
browser->GetHost()->RunFileDialog(FILE_DIALOG_OPEN_FOLDER, ...)
magreenblatt wrote:IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON via CefResourceBundleHandler::GetLocalizedString.
magreenblatt wrote:You need to implement CefResourceBundleHandler, CefApp::GetResourceBundleHandler
class ClientApp : public CefApp, public CefResourceBundleHandler {
...
CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() override {
return this;
}
// Implement CefResourceBundleHandler methods:
bool GetLocalizedString(int string_id, CefString& string) override;
...
};
if (string_id == IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON) {
string = “someLabel”;
return true;
}
return false;
magreenblatt wrote:See the method documentation. A simple implementation would be:
- Code: Select all
if (string_id == IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON) {
string = “someLabel”;
return true;
}
return false;
#ifndef COMMON_CEF_RESOURCE_BUNDLE_HANDLER_IMPL_H
#define COMMON_CEF_RESOURCE_BUNDLE_HANDLER_IMPL_H
#pragma once
#include "include/cef_resource_bundle_handler.h"
#include "include/cef_pack_strings.h"
namespace common
{
class CefResourceBundleHandlerImpl : public CefResourceBundleHandler
{
public:
CefResourceBundleHandlerImpl(void);
// Methods from CefResourceBundleHandler
bool GetLocalizedString(
int string_id,
CefString& string) override;
bool GetDataResource(
int resource_id,
void*& data,
size_t& data_size) override;
bool GetDataResourceForScale(
int resource_id,
ScaleFactor scale_factor,
void*& data,
size_t& data_size) override;
private:
IMPLEMENT_REFCOUNTING(CefResourceBundleHandlerImpl);
~CefResourceBundleHandlerImpl(void);
};
} // namespace common
#endif // COMMON_CEF_RESOURCE_BUNDLE_HANDLER_IMPL_H
#include "cef_resource_bundle_handler_impl.h"
namespace common
{
CefResourceBundleHandlerImpl::CefResourceBundleHandlerImpl(void)
{
LOG(INFO) << "CefResourceBundleHandlerImpl constructed";
}
CefResourceBundleHandlerImpl::~CefResourceBundleHandlerImpl(void)
{
LOG(INFO) << "CefResourceBundleHandlerImpl destructed";
}
bool CefResourceBundleHandlerImpl::GetLocalizedString(
int string_id,
CefString& string)
{
switch (string_id)
{
case IDS_SELECT_UPLOAD_FOLDER_DIALOG_UPLOAD_BUTTON:
{
string = "NEW BUTTON LABEL";
return true;
break;
}
default:
{
break;
}
}
return false;
}
bool CefResourceBundleHandlerImpl::GetDataResource(
int resource_id,
void*& data,
size_t& data_size)
{
return false;
}
bool CefResourceBundleHandlerImpl::GetDataResourceForScale(
int resource_id,
ScaleFactor scale_factor,
void*& data,
size_t& data_size)
{
return false;
}
} // namespace common
...
#include "/path/to/new/class/cef_resource_bundle_handler_impl.h"
...
class ClientApp : public CefApp
{
public:
...
~ClientApp();
CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() override;
...
private:
...
CefRefPtr<CefResourceBundleHandler> cefResourceBundleHandlerImpl;
...
}
...
ClientApp::ClientApp()
{
this->cefResourceBundleHandlerImpl = new common::CefResourceBundleHandlerImpl();
}
ClientApp::~ClientApp()
{
this->cefResourceBundleHandlerImpl = nullptr;
}
...
CefRefPtr<CefResourceBundleHandler> ClientApp::GetResourceBundleHandler()
{
return this->cefResourceBundleHandlerImpl;
}
Users browsing this forum: Google [Bot] and 71 guests