FileInput.hpp

Specs for the FileInput widget (click on to upload a file)

This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2015-2022 Michigan State University MIT Software license; see doc/LICENSE.md

Todo:

Setup FileInput to work outside of web mode as well.

Defines

INCLUDE_EMP_WEB_FILE_INPUT_HPP_GUARD
class FileInput : public internal::WidgetFacet<FileInput>
#include <FileInput.hpp>

FileInput will convert the file to a std::string and pass the result to a designated function.

To create a new file input, you must pass it a void function that takes a const std::string & as its only argument. When a file is loaded, the specified function is called and the body of the file is passed in as the string.

Public Types

using INFO_TYPE = FileInputInfo

Public Functions

inline FileInput(const std::function<void(const std::string&)> &in_cb, const std::string &in_id = "")

Create a new FileInput; supply the function to call with the file contents as a string (and optionally the HTML identifier to be used).

inline FileInput(const std::function<void(File)> &cb, const std::string &in_id = "")

Create a new FileInput; supply the function to call with the file contents as a File object (and optionally the HTML identifier to be used).

FileInput(const FileInput &in) = default

Load a pre-existing FileInput object.

inline FileInput(const Widget &in)
virtual ~FileInput() = default
inline FileInput &Callback(const std::function<void(const std::string&)> &in_cb)

Change the callback function to use when a new file is loaded.

inline FileInput &Autofocus(bool in_af)

Set this FileInput object to have autofocus (or not)

inline FileInput &Disabled(bool in_dis)

Set this FileInput object to be disabled (or reenable it.)

inline bool HasAutofocus() const

Determine if this object currently has autofocus.

inline bool IsDisabled() const

Determine if this object is currently disabled.

Protected Functions

inline FileInputInfo *Info()
inline const FileInputInfo *Info() const
inline FileInput(FileInputInfo *in_info)

Friends

friend class FileInputInfo